Rails 3 - the most annoying deprecation warning

I just successfully converted my Rails 2.3.8 app to Rails 3.0 Release
candidate 2! I will post both the apps on my github account for
everyone else. I do want to clean up the deprecation warnings as best
as I can before I post them though. By far the most frequent
deprecation warning that shows up everywhere, i.e., the console log as
well as command line window when I run tests/cucumber etc. is the
following type:

DEPRECATION WARNING: save(false) is deprecated, please give
save(:validate => false) instead. (called from save at
/home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0.rc2/lib/active_record/validations.rb:43)

Thing is: it is all over the place. I am not even sure where to look
and what to do. It seems like it has nothing to do with save and
everything else. Can someone please explain?

Thanks.

Bharat

DEPRECATION WARNING: save(false) is deprecated, please give
save(:validate => false) instead. (called from save at
/home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0.rc2/lib/active_record/validations.rb:43)

From the 2.3.8 Docs:

(ActiveRecord::Base)
save(perform_validation = true)
Saves the model.

If the model is new a record gets created in the database, otherwise the
existing record gets updated.

If perform_validation is true validations run. If any of them fail the
action is cancelled and save returns false. If the flag is false
validations are bypassed altogether. See ActiveRecord::Validations for
more information.

There’s a series of callbacks associated with save. If any of the
before_* callbacks return false the action is cancelled and save returns
false. See ActiveRecord::Callbacks for further details

(ActiveRecord::Persistence)
save(options)
Saves the model.

If the model is new a record gets created in the database, otherwise the
existing record gets updated.
By default, save always run validations. If any of them fail the action
is cancelled and save returns false. However, if you supply :validate =>
false, validations are bypassed altogether. See
ActiveRecord::Validations for more information.

There’s a series of callbacks associated with save. If any of the
before_* callbacks return false the action is cancelled and save returns
false. See ActiveRecord::Callbacks for further details.

Parker Selbert wrote:

(ActiveRecord::Persistence)
save(options)
Saves the model.

If the model is new a record gets created in the database, otherwise the
existing record gets updated.
By default, save always run validations. If any of them fail the action
is cancelled and save returns false. However, if you supply :validate =>
false, validations are bypassed altogether. See
ActiveRecord::Validations for more information.

There’s a series of callbacks associated with save. If any of the
before_* callbacks return false the action is cancelled and save returns
false. See ActiveRecord::Callbacks for further details.

That portion was from the Rails 3 docs, forgot to add that.

"If save(false) isn't something that
you're calling in your code it is likely in plugins or gems that you're
loading." ---

Thank you for your time. This makes sense. However, there is not a
single place in my application where I am calling save(false) and this
warning is triggered all over the place WITHOUT a reference to the line
of code (in the plugin/gem) that might be triggering it.

I have simply commented it out in the rails 3.0 code since in my
judgement, it is more trouble than worth it?

What do you think?

Bharat

If you're using authlogic, then you might be seeing what I described in issue 161

http://github.com/binarylogic/authlogic/issues#issue/161

-Rob

Rob Biedenharn
Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/
rab@GaslightSoftware.com http://GaslightSoftware.com/

Bharat Ruparel wrote:

Thank you for your time. This makes sense. However, there is not a
single place in my application where I am calling save(false) and this
warning is triggered all over the place WITHOUT a reference to the line
of code (in the plugin/gem) that might be triggering it.

I have simply commented it out in the rails 3.0 code since in my
judgement, it is more trouble than worth it?

What do you think?

Bharat

The "head in the sand" approach isn't usually a good one, but I can
understand your frustration at all of the Deprecation warnings. If you
aren't using it then it is certainly a gem or plugin, and with Rails 3
officially out they will be updated shortly. If they aren't actively
updated you should investigate another solution anyhow =)