On Tue, Apr 7, 2015 at 2:50 PM, mrmanishs <[email protected]> wrote:

> I would like to map an attribute to an object ID.

> Example:
>
> A User  ActiveRecord model exists with an id field

An ActiveRecord "id" is not the same as an "object id" in Ruby, so I'm
not sure I understand what you want. However,

> A Message ActiveRecord model exists with id, from_user_id, to_user_id
>
> I would like from_user_id to map to user.id and to_user_id to map to
> user.id.
>
> What's the best way to accomplish this?

Create it that way? e.g.

Message.create(from_user_id: 1, to_user_id: 2, text: '...' )

HTH, apologies if I've misunderstood your goal,
-- 
Hassan Schroeder ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan
Consulting Availability : Silicon Valley or remote

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yAJnXNRBQzMJKBxx3saKjXRwAHgQdXXmU9p0RVr06YTOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to