[Nitro] [PATCH] Bugfix in __force_#{attr}

Arne Brasseur arne at arnebrasseur.net
Mon Sep 10 07:32:23 EDT 2007

Another small patch, for Og model attributes a method __force_#{attr} is 
dynamically added. This method is used by assign_attributes.


model_instance.assign_attributes('title' => 'Programming Nitro', 
'expensive' => true)

For boolean attributes (with TrueClass or FalseClass as the attribute 
type) this method always gave 'false' for anything but the string 'on'.

The new version correctly handles %w(on off true false), true, false and 
converts anything else to boolean according to Ruby's rules (everything 
is true except false and nil).

I also noticed that the keys in the call to assign_attributes must be 
strings, this right here surprisingly doesn't work:

model_instance.assign_attributes(:title => 'Programming Nitro', 
:expensive => true)

Any thoughts? Should I change this so it can use both?

thank you all,

Arne Brasseur
arne at arnebrasseur.net

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bundle_ab_20070910_2.patch
Type: text/x-patch
Size: 63019 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20070910/aa5c4c3c/attachment-0001.bin 

More information about the Nitro-general mailing list