class project < ActiveRecord::Base
belongs_to :users
belongs_to :sales,
:class_name => :User,
:foreign_key => :sales_id
end
should work.
Saludos!
HoraPe
On Fri, Jun 23, 2006 at 03:49:50PM +0200, mich wrote:> Hello,
>
> I''ve got DB like this:
>
> (roughly)
> create table projects (
> id int auto blabla,
> name varchar(200),
> user_id int,
> sales_id int);
>
> create table users (
> id int auto..,
> name varchar(50));
>
>
> So project.user_id has a foreign key to user.id - all is good.
> Everything works fine.
>
> Now my question..
> How can set a relationship from two different fields to the users table
> ??
> Fx. I will user_is who might be the owner of the project, afterwards I
> would like to assign a salesrep to the project.. so sales_id should also
> be looked up in the users table..
>
> How do I tell rails about this relation ?
>
> TIA,
>
> /mich
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
--
HoraPe
---
Horacio J. Pe?a
horape@compendium.com.ar
horape@uninet.edu