我正在運行設計。除了特定路線之外,我希望所有內容都可以強制登錄。在我的應用程序中,我保存了一個很長的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