Ensure that the relationship between page
and section
is defined:
class Page < ActiveRecord::Base
has_many :sections
end
class Section < ActiveRecord::Base
belongs_to :page
end
With this relationship the following should work as expected:
page = Page.find(1)
page.sections.size