My database has a column called birthday.
The model has a method:
def age
return (birthday.nil? ? -1 : DateTime.now.year - birthday.year)
end
When called from a validation method on a new record, I get:
NameError in ''User should be valid''
undefined local variable or method `birthday'' for
#<User:0x3285e58>
My interpretation after some experimenting is that because it''s a new
record and birthday is not initialized, activerecord doesn''t give me
an accessor called birthday.
What is the ''proper'' way to write the age method?
Thanks,
Pito
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---