On Miércoles, 1 de Julio de 2009 11:53:28 Sylvain escribió:
> Hi again,
> I have two Models has follow:
>
> Class Device
> has_many :links, :foreign_key => "src_device_id"
> has_many :links, :foreign_key => "dst_device_id"

This is wrong, you can't have two associations with the same name, rails will 
ignore the first association. If you try in the console (script/console) 
Device.first.links you can see SQL generated by rails will be use 
dst_device_id.

>
>
> Class Link
> belongs_to :src_device, :class_name => "Device"
> belongs_to :dst_device, :class_name => "Device"

There was a bug in ActiveScaffold and in this case ActiveScaffold failed to 
guess the foreign_key (but it worked if you set foreign_key). I have fixed it 
now.

> or even better (but harder for AS) "(links.src_device_id =
> XXXX) OR (links.dst_device_id = XXXX)

It's not possible because first association is overwritten with second one, so 
rails and ActiveScaffold don't know links association with foreign_key 
src_device_id.

>
> Is it normal? and is there a way to change that?
>
> Thanks in advance,
>
> Sylvain
> 
-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 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