That's cool, thanks. I've got the server running with no errors now but am struggling implementing the checkboxes in my usual manner.
Have just tried this: <%= check_box_tag "radcheck[usernames][]", group.name, @radcheck.groups.include?(group) %> But that gives me an error: undefined local variable or method `group' for #<#<Class: 0x000001016fb650>:0x000001016f3d10> On Nov 7, 7:21 pm, Emmanuel Gomez <[email protected]> wrote: > On Nov 7, 2011, at 10:40 AM, [email protected] wrote: > > > > > > > > > > > I've been following [this tutorial][1] to try and get things working > > but still cannot get it sorted. > > > Relationships are as follows: > > > Radcheck have and belong to many Groups through Radusergroup > > Groups have and belong to many Radcheck through Radusergroup > > > I have this in my models: > > > class Radcheck > > include DataMapper::Resource > > > has n, :radgroups, :model => 'Group', :child_key => > > [:groupname], :parent_key => [:username], :through => :radusergroup > > > end > > The relationship to be traversed has to be defined before defining the > `:through` relationship. In other words: > > ``` ruby > class Radcheck > include DataMapper::Resource > > property :id, Serial > property :name, String > > has n, :radusergroups, :child_key => [:username], :parent_key => [:name] > has n, :radgroups, :through => :radusergroups > end > > class Group > include DataMapper::Resource > > property :id, Serial > property :name, String > > has n, :radusergroups, :child_key => [:groupname], :parent_key => [:name] > has n, :radusers, :through => :radusergroups, :model => 'Radcheck' > end > > class Radusergroup > include DataMapper::Resource > > belongs_to :radusers, :model => 'Radcheck', :child_key => [:username], > :parent_key => [:name] > belongs_to :radgroups, :model => 'Group', :child_key => [:groupname], > :parent_key => [:name] > end > ``` > > The `property` declarations in `Radcheck` and `Group` are, of course, at your > discretion, but you will need to specify the key mapping in the relationship > definitions (though not in the :through relationship definitions, since > :through relationships reflect on the existing relationships that they > traverse). > > Hope that helps, > Emmanuel -- You received this message because you are subscribed to the Google Groups "DataMapper" 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/datamapper?hl=en.
