Deprecation of save(false) for save(:validate => false) (Rails3) #161

Closed
rab opened this Issue Aug 3, 2010 · 37 comments

Comments

Projects
None yet
@rab

rab commented Aug 3, 2010

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

Digging in the call stack, the source of the save is in
authlogic-2.1.5/lib/authlogic/session/callbacks.rb at line 95
http://github.com/binarylogic/authlogic/blob/master/lib/authlogic/session/callbacks.rb#L95

The corrected call should replace false with :validate => false

    def save_record(alternate_record = nil)
      r = alternate_record || record
      r.save_without_session_maintenance(:validate => false) if r && r.changed? && !r.readonly?
    end
@rab

This comment has been minimized.

Show comment Hide comment
@rab

rab Aug 17, 2010

forked and created a pull request for this fix and another in acts_as_authentic/logged_in_status.rb:35+36 named_scope => scope

rab commented Aug 17, 2010

forked and created a pull request for this fix and another in acts_as_authentic/logged_in_status.rb:35+36 named_scope => scope

@lichtamberg

This comment has been minimized.

Show comment Hide comment
@lichtamberg

lichtamberg Aug 31, 2010

Could you apply that patch? thx

The warning is nasty..

Could you apply that patch? thx

The warning is nasty..

@MikieC

This comment has been minimized.

Show comment Hide comment
@MikieC

MikieC Aug 31, 2010

Here are all the places where false is getting passed down to save:

./authlogic/session/callbacks.rb:95: r.save_without_session_maintenance(false) if r && r.changed? && !r.readonly?

./authlogic/acts_as_authentic/password.rb:280: save_without_session_maintenance(false)

./authlogic/acts_as_authentic/password.rb:317: save(false)

./authlogic/acts_as_authentic/persistence_token.rb:56: save_without_session_maintenance(false)

./authlogic/acts_as_authentic/perishable_token.rb:94: save_without_session_maintenance(false)

MikieC commented Aug 31, 2010

Here are all the places where false is getting passed down to save:

./authlogic/session/callbacks.rb:95: r.save_without_session_maintenance(false) if r && r.changed? && !r.readonly?

./authlogic/acts_as_authentic/password.rb:280: save_without_session_maintenance(false)

./authlogic/acts_as_authentic/password.rb:317: save(false)

./authlogic/acts_as_authentic/persistence_token.rb:56: save_without_session_maintenance(false)

./authlogic/acts_as_authentic/perishable_token.rb:94: save_without_session_maintenance(false)

@dmonopoly

This comment has been minimized.

Show comment Hide comment
@dmonopoly

dmonopoly Sep 1, 2010

wait - so what exactly should be done so we can avoid this error?

wait - so what exactly should be done so we can avoid this error?

@lichtamberg

This comment has been minimized.

Show comment Hide comment
@lichtamberg

lichtamberg Sep 1, 2010

# This is deprecated
save(false)  

# change all "save(false)" occurences to   
save(:validate => false)
# This is deprecated
save(false)  

# change all "save(false)" occurences to   
save(:validate => false)
@dmonopoly

This comment has been minimized.

Show comment Hide comment
@dmonopoly

dmonopoly Sep 1, 2010

was this going to be patched up?
should I go in the gems and change all this, or just wait? :O

was this going to be patched up?
should I go in the gems and change all this, or just wait? :O

@herrtreas

This comment has been minimized.

Show comment Hide comment
@herrtreas

herrtreas Sep 3, 2010

+1

+1

@gtd

This comment has been minimized.

Show comment Hide comment
@gtd

gtd Sep 4, 2010

+1

gtd commented Sep 4, 2010

+1

@jsl

This comment has been minimized.

Show comment Hide comment
@jsl

jsl Sep 5, 2010

Please apply this patch

jsl commented Sep 5, 2010

Please apply this patch

@lichtamberg

This comment has been minimized.

Show comment Hide comment
@m3talsmith

This comment has been minimized.

Show comment Hide comment
@m3talsmith

m3talsmith Sep 15, 2010

This is so annoying! Please pull the patch!

This is so annoying! Please pull the patch!

@lichtamberg

This comment has been minimized.

Show comment Hide comment
@lichtamberg

lichtamberg Sep 15, 2010

This pull request breaks rails 2 compability...

This pull request breaks rails 2 compability...

@m3talsmith

This comment has been minimized.

Show comment Hide comment
@m3talsmith

m3talsmith Sep 15, 2010

Then remove the depreciation warning

Then remove the depreciation warning

@lichtamberg

This comment has been minimized.

Show comment Hide comment
@lichtamberg

lichtamberg Sep 15, 2010

The deprecationwarning comes from rails itself..

The deprecationwarning comes from rails itself..

@m3talsmith

This comment has been minimized.

Show comment Hide comment
@m3talsmith

m3talsmith Sep 15, 2010

ok.

ok.

@bjjb

This comment has been minimized.

Show comment Hide comment
@bjjb

bjjb Sep 18, 2010

Umm, so wouldn't it be better to patch the save_without_session_maintenance method itself, if that's the culprit?

I got rid of the deprecation message at the bottom of this gist: http://gist.github.com/586048.

bjjb commented Sep 18, 2010

Umm, so wouldn't it be better to patch the save_without_session_maintenance method itself, if that's the culprit?

I got rid of the deprecation message at the bottom of this gist: http://gist.github.com/586048.

@m3talsmith

This comment has been minimized.

Show comment Hide comment
@m3talsmith

m3talsmith Sep 20, 2010

It seems like you could do a check to see it it's rails 3 or rails two and fire off the right method according to jjbuckley's fix.

It seems like you could do a check to see it it's rails 3 or rails two and fire off the right method according to jjbuckley's fix.

@bjjb

This comment has been minimized.

Show comment Hide comment
@bjjb

bjjb Sep 20, 2010

Sorry, I should've mentioned that my "fix" was purely to remove the warnings under Rails 3 - it will not work in a Rails < 3 application! But I agree with m3talsmith - just wrap that line in a check for the ActiveRecord version. and everyone should be happy.

bjjb commented Sep 20, 2010

Sorry, I should've mentioned that my "fix" was purely to remove the warnings under Rails 3 - it will not work in a Rails < 3 application! But I agree with m3talsmith - just wrap that line in a check for the ActiveRecord version. and everyone should be happy.

@mindtonic

This comment has been minimized.

Show comment Hide comment
@mindtonic

mindtonic Oct 20, 2010

here's an alternative: http://github.com/railsware/authlogic

@metasoarous

This comment has been minimized.

Show comment Hide comment
@metasoarous

metasoarous Nov 7, 2010

Any plans to pull the railsware solution back into the main repo? This is certainly an annoying deprecation message, and it would be nice to keep everything in the original/primary repository.

Any plans to pull the railsware solution back into the main repo? This is certainly an annoying deprecation message, and it would be nice to keep everything in the original/primary repository.

@dmonopoly

This comment has been minimized.

Show comment Hide comment
@dmonopoly

dmonopoly Nov 7, 2010

+1
Could we have a solution once and for all soon?

+1
Could we have a solution once and for all soon?

@mindtonic

This comment has been minimized.

Show comment Hide comment
@mindtonic

mindtonic Nov 7, 2010

+1

+1

@Zelnox

This comment has been minimized.

Show comment Hide comment
@Zelnox

Zelnox Nov 8, 2010

+1

Zelnox commented Nov 8, 2010

+1

@m3talsmith

This comment has been minimized.

Show comment Hide comment
@m3talsmith

m3talsmith Nov 9, 2010

+1

+1

@razmataz

This comment has been minimized.

Show comment Hide comment
@razmataz

razmataz Nov 20, 2010

+0.75

+0.75

@GregM

This comment has been minimized.

Show comment Hide comment
@GregM

GregM Mar 23, 2011

+1

GregM commented Mar 23, 2011

+1

@codegoblin

This comment has been minimized.

Show comment Hide comment
@codegoblin

codegoblin Apr 11, 2011

+1000

+1000

@fguillen

This comment has been minimized.

Show comment Hide comment
@fguillen

fguillen Apr 13, 2011

+1

+1

@kuon

This comment has been minimized.

Show comment Hide comment
@kuon

kuon Apr 28, 2011

+1

kuon commented Apr 28, 2011

+1

@fguillen

This comment has been minimized.

Show comment Hide comment
@fguillen

fguillen Apr 28, 2011

Until this is fixed in the official repository I'm using this:

gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'

And it is working like a charm

Until this is fixed in the official repository I'm using this:

gem 'authlogic', :git => 'git://github.com/odorcicd/authlogic.git', :branch => 'rails3'

And it is working like a charm

@ak47

This comment has been minimized.

Show comment Hide comment
@ak47

ak47 May 13, 2011

+1 pull

ak47 commented May 13, 2011

+1 pull

@imish

This comment has been minimized.

Show comment Hide comment
@imish

imish May 22, 2011

+1

imish commented May 22, 2011

+1

@m3talsmith

This comment has been minimized.

Show comment Hide comment
@m3talsmith

m3talsmith May 26, 2011

Can't someone in charge make this pull yet? This is getting pretty annoying.

Can't someone in charge make this pull yet? This is getting pretty annoying.

@Sujimichi

This comment has been minimized.

Show comment Hide comment
@Sujimichi

Sujimichi Jul 30, 2011

I don't know if its worth mentioning, but I only got this message after I added the "magic" attributes to my User model. After adding the magic attrs I got both this warning and the one described in #120.

Both messages went after I moved up to Rails 3.0.7 (from 3.0.2) and set gem 'authlogic', '>=3.0.2' (was prev just gem 'authlogic').

I don't know if its worth mentioning, but I only got this message after I added the "magic" attributes to my User model. After adding the magic attrs I got both this warning and the one described in #120.

Both messages went after I moved up to Rails 3.0.7 (from 3.0.2) and set gem 'authlogic', '>=3.0.2' (was prev just gem 'authlogic').

@jdxcode

This comment has been minimized.

Show comment Hide comment
@jdxcode

jdxcode Mar 28, 2012

+1

jdxcode commented Mar 28, 2012

+1

@aarthiraj561

This comment has been minimized.

Show comment Hide comment
@aarthiraj561

aarthiraj561 Apr 19, 2012

thanks! worked for me

thanks! worked for me

@jaredbeck

This comment has been minimized.

Show comment Hide comment
@jaredbeck

jaredbeck Jan 23, 2018

Collaborator

I think this was fixed by e4e1dd7 and released as 3.0.0.

If you can still reproduce this issue with a clean install of the latest
version of authlogic and rails (currently 3.6.0 and 5.1.4 respectively), please
create a git repo with a sample app that reproduces the problem, and open a new
issue.

Collaborator

jaredbeck commented Jan 23, 2018

I think this was fixed by e4e1dd7 and released as 3.0.0.

If you can still reproduce this issue with a clean install of the latest
version of authlogic and rails (currently 3.6.0 and 5.1.4 respectively), please
create a git repo with a sample app that reproduces the problem, and open a new
issue.

@jaredbeck jaredbeck closed this Jan 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment