I'm having an issue with overriding accessors; here's my model:
class User
include DataMapper::Resource
property :id, Serial
property :username, String
def username= new_username
@usename = new_username.downcase
end
end
The problem is that, when using a custom accessor like I have here,
the field doesn't get set; it gets set to null. I've found that I can
do this:
def username= new_username
super new_username.downcase
end
And that works fine. Of course, not overriding the accessor works
too.
I copied the example from the documentation (http://rubydoc.info/
github/datamapper/dm-core/master/DataMapper/Property) and had the same
problem with it.
Has the syntax changed? Am I doing something wrong?
Thanks!
PS - if it matters, I'm using dm-core 1.1.0 in Ruby 1.9.2 on Snow
Leopard
--
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.