Vote count:
0
I have two models set up like this:
class Page < ActiveRecord::Base
belongs_to :book
end
class Book < ActiveRecord::Base
has_many :pages
end
I know I can retrieve the book that a given Page belongs to if I have one model, e.g. page.book. But if I have an arbitrary set of pages, can I retrieve all of the books that all of my pages belong to?
asked 1 min ago
Querying one to many with relation in rails?
Aucun commentaire:
Enregistrer un commentaire