Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use inflector to avoid conflicts.

  • Loading branch information...
commit fa6c8ab321fd0c62f6c7b55523045bf849d2578f 1 parent d02f86b
@josevalim josevalim authored
View
3  lib/devise.rb
@@ -317,7 +317,8 @@ def self.add_module(module_name, options = {})
if options[:model]
path = (options[:model] == true ? "devise/models/#{module_name}" : options[:model])
- Devise::Models.send(:autoload, module_name.to_s.camelize.to_sym, path)
+ camelized = ActiveSupport::Inflector.camelize(module_name.to_s)
+ Devise::Models.send(:autoload, camelized.to_sym, path)
end
Devise::Mapping.add_module module_name
View
4 lib/devise/failure_app.rb
@@ -101,7 +101,9 @@ def http_auth_body
def recall_app(app)
controller, action = app.split("#")
- "#{controller.camelize}Controller".constantize.action(action)
+ controller_name = ActiveSupport::Inflector.camelize(controller)
+ controller_klass = ActiveSupport::Inflector.constantize("#{controller_name}Controller")
+ controller_klass.action(action)
end
def warden
View
5 lib/devise/omniauth.rb
@@ -14,8 +14,9 @@
OmniAuth.config.on_failure = Proc.new do |env|
env['devise.mapping'] = Devise::Mapping.find_by_path!(env['PATH_INFO'], :path)
- controller_klass = "#{env['devise.mapping'].controllers[:omniauth_callbacks].camelize}Controller"
- controller_klass.constantize.action(:failure).call(env)
+ controller_name = ActiveSupport::Inflector.camelize(env['devise.mapping'].controllers[:omniauth_callbacks])
+ controller_klass = ActiveSupport::Inflector.constantize("#{controller_name}Controller")
+ controller_klass.action(:failure).call(env)
end
module Devise
View
2  lib/devise/rails/warden_compat.rb
@@ -28,7 +28,7 @@ def deserialize(keys)
klass, id, salt = keys
begin
- record = klass.constantize.to_adapter.get(id)
+ record = ActiveSupport::Inflector.constantize(klass).to_adapter.get(id)
record if record && record.authenticatable_salt == salt
rescue NameError => e
if e.message =~ /uninitialized constant/
View
3  lib/devise/strategies/authenticatable.rb
@@ -157,7 +157,8 @@ def parse_authentication_key_values(hash, keys)
# becomes simply :database.
def authenticatable_name
@authenticatable_name ||=
- self.class.name.split("::").last.underscore.sub("_authenticatable", "").to_sym
+ ActiveSupport::Inflector.underscore(self.class.name.split("::").last).
+ sub("_authenticatable", "").to_sym
end
end
end
View
3  test/devise_test.rb
@@ -58,9 +58,6 @@ class DeviseTest < ActiveSupport::TestCase
assert_equal :fruits, Devise::CONTROLLERS[:kivi]
Devise::ALL.delete(:kivi)
Devise::CONTROLLERS.delete(:kivi)
-
- assert_nothing_raised(Exception) { Devise.add_module(:authenticatable_again, :model => 'devise/model/authenticatable') }
- assert defined?(Devise::Models::AuthenticatableAgain)
end
test 'should complain when comparing empty or different sized passes' do

0 comments on commit fa6c8ab

Please sign in to comment.
Something went wrong with that request. Please try again.