
Property gets 'undefined method' error on first try, fixes itself on second try
Reported by Hugh | March 18th, 2008 @ 05:19 PM
Instantiating a new user and then trying to set or access its 'login' property gives you an error when you first try to do it. But if you do it again, everything works as expected.
>> u = User.new
=> #<User:0x197f238 @new_record=true, @id=nil>
>> u.login = "test"
NoMethodError: undefined method `login=' for #<User:0x197f238>
from (irb):3
>> u.login = "test"
=> "test"
>> u = User.new
=> #<User:0x1967fd4 @new_record=true, @updated_at=nil, @crypted_password=nil, @name=nil, @created_at=nil, @salt=nil, @login=nil, @remember_token=nil, @id=nil, @remember_token_expires_at=nil>
After doing this once, User.new will always work as expected. Here's my model code:
class User < DataMapper::Base
property :name, :string
property :login, :string
property :crypted_password, :string
property :salt, :string
property :remember_token, :string
property :remember_token_expires_at, :datetime
property :created_at, :datetime
property :updated_at, :datetime
end
Comments and changes to this ticket
-
Dan Kubb (dkubb) April 15th, 2008 @ 03:08 AM
- Milestone cleared.
-
Sam Smoot April 28th, 2008 @ 12:55 PM
- State changed from new to invalid
Think this was an error in Validatable. Does not apply to 0.9.0.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »