Hello!
I'm trying to figure out, how to limit choices using select-many tag.
Code is like this:
class Contract < ActiveRecord::Base
...
has_many :devices
has_many :networks
has_many :groups
...
end
class Device < ActiveRecord::Base
...
belongs_to :contract
has_many :group_memberships
has_many :groups, :through => :group_memberships, :accessible => true
...
end
class GroupMembership < ActiveRecord::Base
...
belongs_to :group
belongs_to :device
...
end
class Group < ActiveRecord::Base
...
belongs_to :contract
has_many :group_memberships
has_many :devices, :through => :group_memberships, :accessible =>
true
end
and in application.dryml:
<extend tag="form" for="Group">
<old-form merge>
<field-list: fields="name, devices"/>
</old-form>
</extend>
Now - it's working fine, but each time I edit Group I get select field
with ALL devices. My goal is to limit this list to devices belonging
to THE SAME contarct, as group. I've try something like this in Group
class:
has_many :devices, :through => :group_memberships, :accessible =>
true, :conditions => ['contract_id = ?', self.contract.id]
But it doesn't work as I though it would :(
Any ideas or clues? :)
---
Grzegorz Marszałek
[email protected]
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" 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/hobousers?hl=en.