Walker
Walker

Reputation: 1147

activerecords 'create' is ignoring object property

I recently added a time_zone property to my User table and I'm trying to insert a time zone when I create the user... however, the property is being completely ignored

 user = User.create( :username => user[:username],
                        :name => user[:username],
                        :email => user[:email],
                        :time_zone => user[:time_zone],
                        :password => user[:password],
                        :password_confirmation => user[:password])

I check the log and the insert statement generated includes everything except the time_zone... why?

Could it be because the time_zone has a default value? although this wouldn't make sense...

Thanks

Upvotes: 1

Views: 27

Answers (1)

Walker
Walker

Reputation: 1147

The create property was being ignored because what was being inserted was the same as the default value...

When I tested inserted a User record with a time_zone different than the default time_zone then it actually generated the insert statement with that new time_zone....

Didn't know rails was this good!

Upvotes: 1

Related Questions