On Nov 7, 2011, at 11:58 PM, [email protected] wrote:

>  attr_accessor :usernames in radcheck.rb

Hmmm, familiar with Ruby you are not… 

`attr_accessor` adds a pair of getter/setter methods to the module/class on 
which it is called. It has nothing to do with persistence. By adding it to your 
model, you have inadvertently provided a slot for the value from the form to be 
stored in memory, only to be discarded.

In general, the best advice I can give you is to very clearly formulate what 
you are trying to accomplish, then figure out how to do that *outside of 
Rails*. The very best place is to do so is in a test. If you are allergic to 
tests, you should have a doctor take a look at that. 

But seriously, at least figure out how to do what you want to do in the 
console. Figuring it out away from your form will be time well spent. Once 
you've got a handle on what you're trying to do, and how to do it outside of 
Rails and the form builder, then it will be much easier to understand and 
diagnose how to accomplish your task in a form.

BTW, you are well and truly in Rails-land at this point. That said, let's go 
briefly go over the basics: what is it you are trying to accomplish? My best 
guess is that you want to associate multiple Group resources (instances) with a 
single Radcheck resource (instance). Is that correct? 

The last snippet of form that you provided was attempting to pass an array of 
checkbox value strings (via `params['radcheck']['usernames']`). I'd wager 
that's not what you actually want to do. I'm guessing that you want to define a 
`Radcheck#group_ids=` method (that finds Groups with the given id values and 
associates them with the given Radcheck) and pass an array of group id strings 
from the form (via `params['radcheck']['group_ids']`) instead. But you clearly 
know what you want better than I do.

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.

Reply via email to