Hi All!
I have two models, Book and Picture,and Book can had many pictures ,so I
defined the relationship between them by follow code.
in Book:
has_many :pictures, :foreign_key => :resource_id, :conditions =>
“resource_type = ‘book’”
in Picture
belongs_to :book, :foreign_key => “resource_id”, :conditions =>
“resource_type = ‘book’”
in routes.rb, I add a few lines like this:
map.resources :books do |book|
book.resources :pictures
end
Ends up the url like “books/6/pictures/35.jpg” works fine,but when I add
a link in index view of Books:
<%= link_to “add a cover”, new_picture_path(book) %>
a undefine method error raise,the message told me these is no
new_picture_path method,why this happen?