I have an app with three models:
Client
has_many :papers
Paper
has_many :pages
belongs_to :client
Page
belongs_to :paper
I can do this in code: @paper.client.name
But I am unable to do @paper.page.name NoMethodError is produced
What I am doing wrong? These are all nested models, where Client is at high level.
Your
Paperobject has many pages, so there’s nopagemethod. If you want to get the names of all the pages belonging to aPaperobject, you’ll need to iterate over thepagesassociation: