Morning. I still can't get this going quite... Have my inputs working fine but the values are not saving in my db. Initially there was a warning about attribute 'usernames' not being available, but that was fixed with attr_accessor :usernames in radcheck.rb
I think the habtm statements are incorrect but I can't for life of me work out why. This is what I have currently: class Radcheck include DataMapper::Resource property :id, Serial property :username, String, :required => true, :unique => true property :attribute, String, :required => true, :default => 'User- Password' property :value, String, :required => true property :op, String, :required => true, :default => ':=' attr_accessor :usernames storage_names[:default] = "radcheck" has n, :radusergroup, :child_key => [:username], :parent_key => [:username] has n, :radgroups, :through => :radusergroup end class Group include DataMapper::Resource property :id, Serial property :name, String, :required => true property :description, Text has n, :radusergroup, :child_key => [:groupname], :parent_key => [:name] has n, :radusers, :through => :radusergroup, :model => 'Radcheck' end class Radusergroup include DataMapper::Resource property :username, String, :key => true property :groupname, String property :priority, Integer storage_names[:default] = "radusergroup" belongs_to :radusers, :model => 'Radcheck', :child_key => [:username], :parent_key => [:name] belongs_to :radgroups, :model => 'Group', :child_key => [:groupname], :parent_key => [:name] end Any thoughts? On Nov 7, 10:43 pm, Emmanuel Gomez <[email protected]> wrote: > On Nov 7, 2011, at 2:34 PM, [email protected] wrote: > > > 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) %> > > You've just crossed the threshold from a DataMapper question to a Rails > question :). > > > But that gives me an error: > > > undefined local variable or method `group' for #<#<Class: > > 0x000001016fb650>:0x000001016f3d10> > > I'm guessing that maybe you intend to output one checkbox for each group in a > list of groups… ? The code you supplied omits that iteration, but if that > assumption is correct then something has gone wrong with the iteration (eg., > `@valid_groups.each do |group|;…; end`). > > With more context I might be of more assistance. > > 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.
