Permalink
Browse files

Another attempt to avoid false positives in this warning.

  • Loading branch information...
1 parent 93cf836 commit 72b6a0a0c9216197799802017cc1617e54b3224d @josevalim josevalim committed Feb 16, 2012
Showing with 11 additions and 5 deletions.
  1. +2 −0 lib/devise/rails.rb
  2. +9 −5 lib/devise/rails/routes.rb
View
2 lib/devise/rails.rb
@@ -87,6 +87,8 @@ def respond_to?(method, include_private = false)
end
config.after_initialize do
+ Devise.configure_warden!
+
example = <<-YAML
en:
devise:
View
14 lib/devise/rails/routes.rb
@@ -5,21 +5,25 @@ class RouteSet #:nodoc:
# Ensure Devise modules are included only after loading routes, because we
# need devise_for mappings already declared to create filters and helpers.
def finalize_with_devise!
- finalize_without_devise!
+ result = finalize_without_devise!
- @devise_finalized ||= begin
- if Devise.router_name.nil? && Rails.application && self != Rails.application.routes
+ # If @devise_finalized was defined, it means devise_for was invoked
+ # in this router, so we proceed to generate devise helpers unless
+ # they were already defined (which then @devise_finalizd would be true).
+ if defined?(@devise_finalized) && !@devise_finalized
+ if Devise.router_name.nil? && self != Rails.application.try(:routes)
warn "[DEVISE] We have detected that you are using devise_for inside engine routes. " \
"In this case, you probably want to set Devise.router_name = MOUNT_POINT, where " \
"MOUNT_POINT is a symbol representing where this engine will be mounted at. For " \
"now Devise will default the mount point to :main_app. You can explicitly set it" \
" to :main_app as well in case you want to keep the current behavior."
end
- Devise.configure_warden!
Devise.regenerate_helpers!
- true
+ @devise_finalized = true
end
+
+ result
end
alias_method_chain :finalize!, :devise
end

0 comments on commit 72b6a0a

Please sign in to comment.