On 5 March 2010 16:17, Andy Jeffries <[email protected]> wrote:
>> Or change the setter (rather than messing around with filters ;-)
>>
>> def username=(value)
>>  write_attribute(:username, value.upcase)
>> end
>
> Is the setter called if you assign to the attributes hash (e.g. with new or
> create)?
> I guess it must be, but I'd generally put that in a callback to be sure :-)
> Cheers,
>

ooo.... good question - don't know without testing it...

>> User.new(:username => "fred")
=> #<User id: nil, role_detail_id: nil, title: "FRED", first_name:
nil, last_name: nil>

yup, looks that way.

But more to the point, I don't like changing users' input before
storing it in the DB. We've shown how you *can* do it, and you've said
you *need* to, but I'd wonder whether that's really a *want* to...
either way... it works either way.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en.

Reply via email to