Hi, Anthony,
maybe you want to try something along the lines of:
class Problem < ActiveRecord::Base
belongs_to :submitter, :class_name => ''Person'',
:foreign_key =>
''submitter_id''
belongs_to :agent, :class_name => ''Person'', :foreign_key
=>
''assigned_to_id''
end
(untested, but should do it)
Best Regards
Jan Prill
2006/2/3, Anthony <portal33@gmail.com>:>
> Hi all
>
> I''m still waiting on my Agile Rails book to arrive - in the
meantime ...
> As an exercise I''m making a Help Desk application.
> If I have a Problems table with two foreign keys to a People table,
> how do I set up my models, problems_controller list method, and then
> simply display say my problem submitter person? Here is what I have so
> far:
>
> Problems table with columns:
> id
> description
> submitter_id (foreign key to People table)
> assigned_to_id (foreign key to People table)
> etc
>
> People table with columns:
> id
> name
>
> models:
> class Problem < ActiveRecord::Base
> has_many :people
>
> class Person < ActiveRecord::Base
> has_many :problems
>
> problem_Controller:
> def list
> @submitter = Person.find(params[:submitter_id] ???
>
> views:problems:list.rhtml
> <td><%= problem.submitter.name %></td> ???
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060203/2927240d/attachment-0001.html