Ruby on Rails Thursday, March 31, 2011

I am posting a related question in the same thread.
It is more of a philosophical question.
Can anybody please give me some philosophical explanation why the
following behavior of ActiveRecord is considered ok (or should i submit
a bug report/feature request?):

In console:
> p = Person.create(:name=>'Bill')
> p.destroy
> p.name # => "Bill"
> p.save # => true
Nothing is saved in the database, but what disturbs me more is that
"save" returned true in such case.

A more elaborate version:
> p = Person.create(:name=>'Bill')
> p.id # => 1
> pp = Person.find(1)
> pp.destroyed
> p.persisted? => true
> p.destroyed? => false
> p.save # => true
but the database is empty.
Again, what bothers me the most is the "true" returned by "save".

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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment