Reputation: 155
I am running devise. I want everything to force sign-in except a specific route. In my app I'm saving a long url and using a short url to point back to my app to grab the long url for a redirect. An external user that is not logged in needs to be able to follow that short url back and grab the long url for an external redirect. for example localhost.com/WdeFrs pulls the long link from the database and redirects to the site....google.com as example. Everything works except when you follow the link back it forces a login. It needs to work without login Can someone help clarify the fix. Thank you
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
Upvotes: 0
Views: 1839
Reputation: 693
The before_action
option except
expects an action name, not a controller name. As is, your code is skipping authentication for any action named urls
.
To skip authentication for urls#shortcustom
and urls#shortened
, you need to include
skip_before_action :authenticate_user!, :only => [:shortcustom, :shortened]
in your UrlsController
.
Upvotes: 3