Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added a few Rails3 updates #196

Closed
wants to merge 4 commits into from

6 participants

@james2m

I've added a few Rails3 updates for deprecated features in ActiveRecord;

save(false) => save(:validate => false)
named_scope => scope

James

@andycroll

This would be splendid...

@chirply

+1

@r38y

+1

@jjb
jjb commented

hi-- i'm going to try to maintain the One True Rails 3 Fork :) please send your pull request to https://github.com/jjb/authlogic

@jjb
jjb commented

Okay -- I've merged these changes into my fork. Check them out, and send over any other contributions.

@ghost

This has been pulled in from alternate pull request. Thanks.

@ghost ghost closed this
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
10 lib/authlogic/acts_as_authentic/logged_in_status.rb
@@ -31,9 +31,13 @@ def self.included(klass)
klass.class_eval do
include InstanceMethods
-
- named_scope :logged_in, lambda { {:conditions => ["last_request_at > ?", logged_in_timeout.seconds.ago]} }
- named_scope :logged_out, lambda { {:conditions => ["last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago]} }
+ if ActiveRecord::VERSION::MAJOR >= 3
+ scope :logged_in, where("last_request_at > ?", logged_in_timeout.seconds.ago)
+ scope :logged_out, where("last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago)
+ else
+ named_scope :logged_in, lambda { {:conditions => ["last_request_at > ?", logged_in_timeout.seconds.ago]} }
+ named_scope :logged_out, lambda { {:conditions => ["last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago]} }
+ end
end
end
View
4 lib/authlogic/acts_as_authentic/password.rb
@@ -277,7 +277,7 @@ def reset_password
# Resets the password to a random friendly token and then saves the record.
def reset_password!
reset_password
- save_without_session_maintenance(false)
+ save_without_session_maintenance(ActiveRecord::VERSION::MAJOR >= 3 ? {:validate => false} : false)
end
alias_method :randomize_password!, :reset_password!
@@ -314,7 +314,7 @@ def transition_password?(index, encryptor, crypted, check_against_database)
def transition_password(attempted_password)
self.password = attempted_password
- save(false)
+ save(ActiveRecord::VERSION::MAJOR >= 3 ? {:validate => false} : false)
end
def require_password?
View
2  lib/authlogic/acts_as_authentic/perishable_token.rb
@@ -91,7 +91,7 @@ def reset_perishable_token
# Same as reset_perishable_token, but then saves the record afterwards.
def reset_perishable_token!
reset_perishable_token
- save_without_session_maintenance(false)
+ save_without_session_maintenance(ActiveRecord::VERSION::MAJOR >= 3 ? {:validate => false} : false)
end
# A convenience method based on the disable_perishable_token_maintenance configuration option.
View
2  lib/authlogic/acts_as_authentic/persistence_token.rb
@@ -53,7 +53,7 @@ def reset_persistence_token
# Same as reset_persistence_token, but then saves the record.
def reset_persistence_token!
reset_persistence_token
- save_without_session_maintenance(false)
+ save_without_session_maintenance(ActiveRecord::VERSION::MAJOR >= 3 ? {:validate => false} : false)
end
alias_method :forget!, :reset_persistence_token!
View
2  lib/authlogic/controller_adapters/rails_adapter.rb
@@ -14,7 +14,7 @@ def cookies
end
def cookie_domain
- @cookie_domain_key ||= Rails::VERSION::STRING >= '2.3' ? :domain : :session_domain
+ @cookie_domain_key ||= ActiveRecord::VERSION::STRING >= '2.3' ? :domain : :session_domain
controller.request.session_options[@cookie_domain_key]
end
View
2  lib/authlogic/session/callbacks.rb
@@ -92,7 +92,7 @@ def persist
def save_record(alternate_record = nil)
r = alternate_record || record
- r.save_without_session_maintenance(false) if r && r.changed? && !r.readonly?
+ r.save_without_session_maintenance(ActiveRecord::VERSION::MAJOR >= 3 ? {:validate => false} : false) if r && r.changed? && !r.readonly?
end
end
end
Something went wrong with that request. Please try again.