Skip to content

Commit

Permalink
Fix infinite redirect in Rails 4.2 authenticated routes. Closes #3643
Browse files Browse the repository at this point in the history
  • Loading branch information
abevoelker committed Jun 27, 2015
1 parent 1819208 commit aa675f7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/devise/failure_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,13 @@ def scope_url

config = Rails.application.config

if config.respond_to?(:relative_url_root) && config.relative_url_root.present?
opts[:script_name] = config.relative_url_root
# Rails 4.2 goes into an infinite loop if opts[:script_name] is unset
if (Rails::VERSION::MAJOR >= 4) && (Rails::VERSION::MINOR >= 2)
opts[:script_name] = (config.relative_url_root if config.respond_to?(:relative_url_root))
else
if config.respond_to?(:relative_url_root) && config.relative_url_root.present?
opts[:script_name] = config.relative_url_root
end
end

router_name = Devise.mappings[scope].router_name || Devise.available_router_name
Expand Down

4 comments on commit aa675f7

@kont-noor
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting opts[:script_name]=nil makes the problem described below:
http://stackoverflow.com/questions/32520617/no-route-matches-get-accounts-sign-in-when-use-devise-from-mounted-engine

Which kind of problem produces unset opts[:script_name]?

@abevoelker
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #3705

@sloops77
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue affects our app running rails 4.1.12

@sebbean
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sloops77 fix it? i'm right there with ya

Please sign in to comment.