Robert, it does not seem like i was changing attributes in-place.

Here is what is going on, i do not understand how it can be a desired
behavior:

I created a test application:

$ rails new test_app
$ cd test_app
$ rails generate model Person name:string age:integer
$ rake db:migrate

In console:

> p = Person.create(:name=>"Johny", :age=>30)
> p.id             # => 1
> p.id = 2         # => 2
> p.save           # => true
No change in the database!
> p.id             # => 2
> p.name = "Jim"   # => "Jim"
> p.save           # => true
No change in the database
> p.name           # => "Jim"
> p.id = 1         # => 1
> p.save           # => true
No change in the database
> p.age = 31       # => 31
> p.save           # => true
In the database, the age became 31, but the name stayed "Johny"!
> p.name           # => "Jim"
> p.name.object_id # => 2155015240
> p.name = "Jim"   # => "Jim"
> p.name.object_id # => 2154887680
> p.save           # => true
No change in the database!
> p.name = "Jimmy" # => "Jimmy"
> p.name.object_id # => 2154859980
> p.save           # => true
Finally, the name changed in the database!

Alexey.

-- 
Posted via http://www.ruby-forum.com/.

-- 
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