I implemented a user login/logout system from this tutorial: http://www.aidanf.net/rails_user_authentication_tutorial It has seperate screens for every action: login, change password etc. When you logout it redirects you to the login screen. I changed it so that the options are all at the top of my standard app screens (such as 'list' and 'show'). Now when you logout, it tries to take you to the login screen, which is now redundant. I hardcoded it to return me to the 'list' page after logging in or logging out, and that works ok in that you can log in and out happily, staying on the list screen all the time. But, the problem is that when the user logs in or out on the 'show' page, i want to stay on the 'show' page, and similarly for other pages i've not got round to doing yet. In other words, the log in and log out shouldn't change pages, it should go stay on the current page. Does anyone know the best way to implement this? Here's my current code in case that helps. in the logged_in partial, shown at the top of my 'list' and 'show' pages: <% user = session[:user] %> <%= "You are logged in as " %> <strong> <%= user.login %> </strong> <span> </span> <%= link_to 'Log out', :controller => "user", :action => "logout" %> <span> </span> <%= link_to 'Change password', :controller => "user", :action => "change_password" %> <br/> logout calls this action, in UserController: def logout session[:user] = nil flash[:message] = 'Logged out' #hardcoded to return to the list page #(newspipe is the name of my app) redirect_to :controller => "newspipe", :action => "list" end How can i make it stay on the page it was at instead of hardcoding a page like above? thanks in advance for any advice!
on 2007-07-23 20:26