rails 3 newbie, with the general question of adding an extra route after scaffolding.
I create a scaffold for books ... Which works great and provides a nice index page.
The Index page displays all the books in the system. I would like to add the '/ books / yours' page, which shows the books created by the user. I already added user_id to the book table to work when users create new books. But I can’t figure out how to add your page ... Here's what I did:
In books_controller.rb added:
def yours
@books = Books.all
respond_to do |format|
format.html
format.xml { render :xml => @notes }
end
end
Then I added the views / books / yours.html.erb page with only the H1 tag that says bingo ...
Then in routes.rb I added:
Cline :: Application.routes.draw do
resources :books
devise_for :users
match '/books/yours', :to => 'books#yours'
root :to => 'pages#home'
But that won't work? What did I do wrong? thanks!