Mapping external objects locally to arbitrarily named columns

Hi all,

I'm working on an app where I have a simplified set up like this:

mark j. hughes пишет:

class User < ActiveRecord:Base
end

class Task < ActiveRecord::Base
  composed_of :requester, :class_name => 'User', :mapping => [ [
:requester, :id ] ]
  composed_of :assignee, :class_name => 'User', :mapping => [ [
:assignee, :id ] ]
end
  

class Task < ActiveRecord::Base
  belongs_to :requester, :class_name => 'User', :foreign_key => 'requester'
  belongs_to :assignee, :class_name => 'User', :foreign_key => 'assignee'
end

You can RDoc everything else.

I also suggest you to rename columns to requester_id and assignee_id.

Wow. How embarassing...

Thanks for your reply, Maxim. Ex post facto, it makes total sense, but
it just didn't appear intuitive that the foreign_key is actually the
local key, since belongs_to is defining a backwards relationship from
another object/table.

Thanks so much!