# Problem with active record table relation

**URL:** <https://www.ruby-forum.com/t/problem-with-active-record-table-relation/88286>\
**Category:** Rails\
**Created:** [March 9, 2007, 12:38pm UTC](https://www.ruby-forum.com/t/problem-with-active-record-table-relation/88286 "2007-03-09T12:38:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![claudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7cd45c/32.png) [@claudio](https://www.ruby-forum.com/u/claudio)\
**Post date:** [March 9, 2007, 12:38pm UTC](https://www.ruby-forum.com/t/problem-with-active-record-table-relation/88286/1 "2007-03-09T12:38:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![claudio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/7cd45c/32.png) [@claudio](https://www.ruby-forum.com/u/claudio)\
**Post date:** [March 9, 2007, 3:43pm UTC](https://www.ruby-forum.com/t/problem-with-active-record-table-relation/88286/2 "2007-03-09T15:43:29Z")

</div>

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.
