我正在运行设计。除了特定路线之外,我希望所有内容都可以强制登录。在我的应用程序中,我保存了一个很长的URL并使用一个简短的URL指向我的应用程序以获取重定向的长URL。未登录的外部用户需要能够追踪该短网址并获取外部重定向的长网址。例如localhost.com/WdeFrs从数据库中拉长链接并重定向到以.... google.com为例。一切正常,除非你按照链接返回它强制登录。 它需要工作,无需登录有人可以帮助澄清修复。谢谢设计before_action:验证异常
application_controller.rb
before_action :authenticate_user!, :except => [:urls]
的routes.rb
resources :urls
get "/:short_url", to: "urls#shortcustom"
get "shortened/:short_url", to: "urls#shortened", as: :shortened
您不希望登录用户使用哪种方法? – Vishal
得到“/:short_url”,以:“urls#shortcustom”我想是我想要例外。 – Jrinard
请在您的网址控制器中尝试此“skip_before_filter:authenticate_user !,:only =>:shortcustom”。 – Vishal