I am using Rails 3.2.7. I have a controller and a action as it's shown below:
class BookController < ApplicationController
def list
@books = Book.find(:all)
end
end
I also created a model with the name book.rb
under model and a list.rhtml
inside \app\views\book
folder. When I hit http://127.0.0.1:3000/book/list
, I am getting this error:
No route matches [GET] "/book/list"**
Here's config/routes.rb
:
Ravi::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
# rest of the explanations in default "config/routes.rb"
end
Your router config is all commented out, you need to add the rules yourself.
Try add the below:
resources :books do
get 'list', :on => :collection
end
And access with: http://127.0.0.1:3000/books/list