El Monday 20 April 2009 15:18:43 Rafael Maus escribió:
> Hello,
>
> It doesn't seem to work.
> I'll try to explain it better, i have model A and B.
>
> A has_many :B
> B belongs_to :A
>
> This will give me the attribute :a on model, controller B.
> What i need is a second reference from A to B.
> On database level table B would have 2 foreign keys from table A.
> How do i proceed?

class A
has_many :bs
end

class B
belongs_to :a
belongs_to :a2, :class_name => 'A'
end

table bs must have fields a_id and a2_id


>
> Thanks,
>
> 2009/4/16 G. Sobrinho <[email protected]>
>
> >  I think you need to change the second association:
> >
> > User
> >   belongs_to :company
> >   belongs_to :regional_company, :class_name => 'Company'
> >
> > and into controller you use regional company and not regional_company_id
> >
> >
> > --
> > Regards,
> > Gabriel Sobrinho
> >
> > Em Qui, 2009-04-16 às 07:29 -0700, Rafael escreveu:
> >
> > Hello,
> >
> > Let say i have this scenario:
> >
> > Company
> >    has_many: users
> >
> > User
> >    belongs_to: company
> >    belongs_to :company, :foreign_key => 'regional_company_id'
> >
> > On my controller i have:
> >     columns[:regional_company_id].label = "Associated to company"
> >     columns[:company].label = "Company"
> >     config.columns[:company].form_ui = :select
> >     config.columns[:regional_company_id].form_ui = :select
> >
> > In this case every user has his own company, and is associated to a
> > regional company.
> >
> > How do i get the "regional_company_id" to be filled with companies
> > when
> > i'm about do add a new user?
> >
> > Thanks,
>
> 


-- 
Sergio Cambra .:: entreCables S.L. ::.
Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to