Problem with active record table relation

I have two tables cms_pages and cms_menus
cms_menus has a foreign key to cms_pages.id so when i create a new link
i can
releate to a page.
Insert is fine, but when i do a list of cms_menus and i want to know the
page name
i just put menu.cms_page.name but i get an error that cms_page is nil,
now
what is driving me crazy is the fact that if i do an
menu.cms_page.inspect i have all the information of that page. I tried
with
menu.cms_page[:name]
menu.cms_page[‘name’]
menu.cms_page.name

NOTHING, all the ohters models releation works fine why i have this
here!!!1
Thanks
claudio

I can’t think of any reason for that to not work other than that you
have
mistakenly used a bad field name… ie cms_page.name is not a valid
reference. If you can reference menu.cms_page at all, then it should be
returning a full AR model, and you should be able to use it like any
other
model.

If you could include the class definitions and maybe table definitions,
might be able to help more.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs