Ruby on Rails first steps

154 views Asked by At

I have installed ROR+apache2 on my Linux VM (TurnKey Rails VM image) and making first steps folowing http://guides.rubyonrails.org/getting_started.html this guide

i have stucked on adding resource calling articles. What i have done my routes.rb:

root@rails www/blog# cat ./config/routes.rb 
Blog::Application.routes.draw do

  resources :articles

  root 'welcome#index'



end

my rake routes

root@rails www/blog# rake routes
      Prefix Verb   URI Pattern                  Controller#Action
    articles GET    /articles(.:format)          articles#index
             POST   /articles(.:format)          articles#create
 new_article GET    /articles/new(.:format)      articles#new
edit_article GET    /articles/:id/edit(.:format) articles#edit
     article GET    /articles/:id(.:format)      articles#show
             PATCH  /articles/:id(.:format)      articles#update
             PUT    /articles/:id(.:format)      articles#update
             DELETE /articles/:id(.:format)      articles#destroy
        root GET    /                            welcome#index

then folowing guide:

rails g controller articles

after that in browser "/" working fine, im getting my "hello, rails" but "/articles/" or "/articles/new" returns 404 - not found. (The page you were looking for doesn't exist.)

my views folder

views  ls -al
total 20
drwxrwxrwx 5 www-data www-data 4096 Jun 10 05:02 .
drwxrwxrwx 8 www-data www-data 4096 Jun 10 04:40 ..
drwxrwxrwx 2 www-data www-data 4096 Jun 10 05:02 articles
drwxrwxrwx 2 www-data www-data 4096 Jun 10 04:40 layouts
drwxrwxrwx 2 www-data www-data 4096 Jun 10 04:49 welcome

my article controller code:

class ArticlesController < ApplicationController
end

Many time spended Google has no result

The question is what am i doing wrong, and how can i debug this like issues. Thx!

1

There are 1 answers

2
Deutro On

The last part of the URL tells Rails which controller and which action in the controller should be called. For your example: /actions/new refers to the controller 'actions_controller.rb' and to the action

def new
end

If you do not define something in your controller action rails will show the view which has the same name as your controller action. In this case you must have this file:

views\actions\new.html.erb

I guess this is the file you haven't created yet.