On Dec 18, 10:24 pm, tesla
<fatihdu...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>
wrote:> hi i have books_controller(action new index show create update..) by
> scaffolding and i add these lines to my program
>
> ****books_controller action
> def buy
> @book = Book.find(params[:id])
> @book.user = current_user
> end
>
> ****routes.rb
> map.resources :books, :collection => { :buy => :get }
>
> ****books_ index.html.erb
> <%= link_to ''buy'', buy_book_path(book) %>
>
> but when i am logging to books_index page
>
> NoMethodError in Books#index
> undefined method `buy_book_path'' for
#<ActionView::Base:0x64a45b0>
> why i''m getting this error?
Because the name of the route is buy_books (because you''ve said that
the buy verb applies to the collection of books as a whole).
If you change your routes stuff to :member => {:buy => :get} then
you''ll get buy_book instead of buy_book. (Remember that you can see
the names of all the routes by running rake routes)
Fred> --
> View this message in
context:http://old.nabble.com/NoMethodError-in-Books-index-tp26850510p2685051...
> Sent from the RubyOnRails Users mailing list archive at Nabble.com.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.