Record Identification with :has_one

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: = 2, = 1

form_for ( [:user, @user.profile])

and it will create the proper route:

and use 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:

It will use for the :user_id instead. Any thoughts?

I am mapping the resource this way:

map.resources :users, :has_one => :profile

Any thoughts?

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?

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