First Steps of Ruby on Rails
I have installed ROR + apache2 on my Linux VM (TurnKey Rails VM image) and took the first steps below http://guides.rubyonrails.org/getting_started.html in this tutorial
I added that I am adding articles to call resources. 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 follow the directions:
rails g controller articles
after that in the browser "/" works fine, I get "hello rails", but "/ articles /" or "/ articles / new" returns 404 - not found. (The page you were looking for does not 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 code:
class ArticlesController < ApplicationController
end
Much time spent by Google has no effect
The question is what am I doing wrong and how can I debug problems like this. thank!
source to share
The last part of the URL tells Rails which controller to call and which action in the controller. For your example: / actions / new refers to the controller "actions_controller.rb" and to the action
def new
end
If you don't define something in your controller, a view with the same name as your controller action will be displayed in the action rails. In this case, you should have this file:
views\actions\new.html.erb
I guess this is a file you haven't created yet.
source to share