One model, several relations to another model...

Hi all,

I don't know a better title for my question, sorry about that.

The problem I'm having is that I've got no clue how to do this:

Table issues:
Column created_by
Column closed_by

Both of those columns will hold User#id's. For what I've read and
understood in the API, you can do:

Class Issue < AR::B
  belongs_to :created_by, :class_name => :user
  belongs_to :closed_by, :class_name => :user
end

But then, in my parent class:

Class User < AR::B
  has_many :? # Issues trough created_by
  has_many :? # Issues trough updated_by
end

I've stopped here because I feel I'm not going in the right
direction...

When you say, it sounds so easy...

Thanks a lot, again! =)

Ok,

Here are the associations:

Class Issue < AR::B
  belongs_to :creator, :class_name => :user, :foreign_key
=> :created_by
  belongs_to :solver, :class_name => :user, :foreign_key => :closed_by
  belongs_to :owner, :class_name => :user, :foreign_key
=> :assigned_to
end

Class User < AR::B
  has_many :created_issues, :class_name => :issue, :foreign_key
=> :created_by
  has_many :closed_issues, :class_name => :issue, :foreign_key
=> :closed_by
  has_many :assigned_issues, :class_name => :issue, :foreign_key
=> :assigned_to
end

If I do:

@issues = Issue.find(:all, :include => :owner )

I get error:

can't convert Symbol into String

Stack:

C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:1347:in `type_name_with_module'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:1746:in `compute_type'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
reflection.rb:125:in `send'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
reflection.rb:125:in `klass'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1561:in `initialize'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1459:in `new'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1459:in `build_join_association'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1442:in `build'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1445:in `build'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1444:in `each'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1444:in `build'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1385:in `initialize'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1123:in `new'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1123:in `find_with_associations'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1122:in `catch'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
associations.rb:1122:in `find_with_associations'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:1232:in `find_every'
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
base.rb:503:in `find'
app/controllers/issues_controller.rb:5:in `index'

Fixed.

Instead of using symbols for :class_name => I used strings.

So :class_name => :user became :class_name => 'User'.