# Record Identification with :has\_one

**URL:** <https://www.ruby-forum.com/t/record-identification-with-has-one/125790>\
**Category:** Rails\
**Created:** [January 12, 2008, 1:51am UTC](https://www.ruby-forum.com/t/record-identification-with-has-one/125790 "2008-01-12T01:51:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [January 12, 2008, 1:51am UTC](https://www.ruby-forum.com/t/record-identification-with-has-one/125790/1 "2008-01-12T01:51:38Z")

</div>

I’m having an issue with the record identification. If I have a :has\_one  
resource relationship mapped in routes.rb I can properly reference that  
in form\_for with:

for example: @user.id = 2, @user.profile.id = 1

form\_for ( [:user, @user.profile])

and it will create the proper route:  
…/user/2/profile/

and use @user.id for the :user\_id

however if I try the same convention in link\_to:  
link\_to “link” [:user, @user.profile]

the format of the URL is different:  
…/user/1/profile/

It will use @user.profile.id for the :user\_id instead. Any thoughts?

I am mapping the resource this way:

map.resources :users, :has\_one =\> :profile

Any thoughts?

---

<div class="post-metadata">

**Author:** ![stickstone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@stickstone](https://www.ruby-forum.com/u/stickstone)\
**Post date:** [January 12, 2008, 2:02am UTC](https://www.ruby-forum.com/t/record-identification-with-has-one/125790/2 "2008-01-12T02:02:41Z")

</div>

I actually just noticed that the form\_for is doing the same thing as the  
link\_to… this seems like an oversight where the :has\_one resource  
relationships weren’t taken into consideration… or maybe I’m doing  
something wrong. Any pointers?
