nr: #1 dodano: 2016-12-28 20:12
We can use store_location_for which stores the provided location to redirect the user after signing in.
And in your controller you can add:
before_action :authenticate_user!, :unless => :devise_controller? # This prevent the infinite redirects.
This code above will do the trick for specific controller as you mentioned in your question, and redirect user to sign up page instead of login page. If you would like to use only on certain links in your view you can check the code I posted below EDIT.
You can simple check if
!current_user and when user click on the link, it will be redirected to sign up page. This code below will return user to the previous page for sure. You can put the code below to your views, and use
if else as well:
<% if !current_user %>
<%= link_to 'Register', new_user_registration_path %>
<% end %>
before_filter syntax is deprecated in Rails 5.0 and will be removed in Rails 5.1