Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Rails3 + subdomain working #195

Closed
wants to merge 5 commits into from

4 participants

@arunagw

Hi,

Added a code to work with Rails3 Application with Sub Domain feature.

Before test was failing for AuthenticatesManyTest for scoping with company.

Added a little code to make this working. Also found this problem in opned issue.

May be this path works for you. I have tested this on ruby-1.9.1-p378. Running rake test giving me confidence that i am pretty good.

Cheers,
Arun

@arunagw

Any updates??

@phoozle

Thanks Arun for fixing this, I'm glad someone has addressed the issue.

Hope the pull is accepted soon.

@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

@ghost

Thanks, these have been added through another pull request.

@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
Commits on Jan 7, 2011
  1. @james2m @jjb

    Added check for Rails 3 in password#save and passed :validate => fals…

    james2m authored jjb committed
    …e to stop deprecation warnings
  2. @james2m @jjb

    Added check for Rails 3 calling save_without_session_maintenance and …

    james2m authored jjb committed
    …passed :validate => false to stop deprecation warnings
  3. @james2m @jjb

    Updated use of named_scopes to scopes when Rails 3

    james2m authored jjb committed
  4. @james2m @jjb

    Changed the Rails 3 check to a check for ActiveRecord 3

    james2m authored jjb committed
Commits on Jan 8, 2011
  1. @arunagw

    Fixed failing test AuthenticatesManyTest, scoping with account and co…

    arunagw authored
    …mpany is working when using subdomain.
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
6 lib/authlogic/authenticates_many/base.rb
@@ -38,11 +38,13 @@ module Base
# separate cookies for each account, assuming a user is logging into mroe than one account. Authlogic can take care of this for you by
# prefixing the name of the cookie and sessin with the model id. You just need to tell Authlogic to do this by passing this option.
def authenticates_many(name, options = {})
- options[:session_class] ||= name.to_s.classify.constantize
+ options[:session_class] ||= name.to_s.classify.constantize
options[:relationship_name] ||= options[:session_class].klass_name.underscore.pluralize
class_eval <<-"end_eval", __FILE__, __LINE__
def #{name}
- find_options = #{options[:find_options].inspect} || #{options[:relationship_name]}.scope(:find)
+ relation_sql = #{options[:relationship_name]}.scoped.to_sql
+ default_find_options = {:conditions => relation_sql[(relation_sql.rindex("WHERE")+5)..relation_sql.length].lstrip!}
+ find_options = #{options[:find_options].inspect} || default_find_options
find_options.delete_if { |key, value| ![:conditions, :include, :joins].include?(key.to_sym) || value.nil? }
@#{name} ||= Authlogic::AuthenticatesMany::Association.new(#{options[:session_class]}, find_options, #{options[:scope_cookies] ? "self.class.model_name.underscore + '_' + self.send(self.class.primary_key).to_s" : "nil"})
end
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
View
1  test/test_helper.rb
@@ -16,7 +16,6 @@ def [](key)
end
-ActiveRecord::Schema.verbose = false
begin
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
Something went wrong with that request. Please try again.