Rails devise 对xls文件访问401异常的Redirect处理
1.\config\initializers\devise.rb
config.navigational_formats = ["*/*", :html,:xls]
config.warden do |manager|
manager.failure_app = CustomFailure
end
2.\lib\autoloads\custom_failure.rb
class CustomFailure < Devise::FailureApp def redirect_url #return super unless [:worker, :employer, :user].include?(scope) #make it specific to a scope new_user_session_url(:subdomain => 'secure') end # You need to override respond to eliminate recall def respond if http_auth? http_auth else redirect end end end
3.\config\application.rb
config.autoload_paths += %W(#{config.root}/lib/autoloads)
posted on 2014-01-27 13:23 leonworld2011 阅读(282) 评论(0) 收藏 举报
浙公网安备 33010602011771号