Redirect :back unless members controller?

I’d like to do something like this when members log out:

redirect_to :back unless :back.controller==‘members’ (then redirect to
main site index)

Anybody know a way?



I think someone told me to rtfm when I asked this question about a
month ago. I did read “it”, and hunted around but it wasn’t at all
obvious to me, and I was really glad when someone helped out, so
hopefully I can recycle the help a bit.

If I understand your problem correctly, the trick is in getting the
action that was last called. This can be found in the params hash.
It’s useful to throw a <%= debug params %> in a page and take a look
at it. It got :action and :controller so in a page you can do this:

<% if @params[:action] == “members_action” %>
…do some stuff
<% else %>
…do some other stuff
<% end %>

or something similar in an .rb file without the brackets.

This code will dump out your session info and params info in a page.

<% if ENV[‘RAILS_ENV’] == ‘development’ %>
<%= debug session %>
<%= debug params %>
<% end %>

got it from here:

Hopefully, some of that helps.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs