How can I get the current path which is processed by rails?


#1

Hi all,

I want something like action_name in my controller which could store
the current path, say /categories/1;edit. Is there any way to get
this? Thanks.

allen


#2

allen wrote:

Hi all,

I want something like action_name in my controller which could store
the current path, say /categories/1;edit. Is there any way to get
this? Thanks.

allen

There’s lots of interesting stuff to be found in the ENV hash. Such
as…

ENV[‘REQUEST_PATH’]


http://www.5valleys.com/


#3

Is there a list anywhere of what all is usually in ENV?

Thanks!


#4

removed_email_address@domain.invalid wrote:

Is there a list anywhere of what all is usually in ENV?

Thanks!

It depends on your sever setup, but doesn’t usually change unless the
admin responsible for the server changes it. Try pasting this
temporarily in one of your views…

ENV

    <% ENV.keys.each do |key| %>
  • ENV['<%= key %>'] = <%= ENV[key] %>
  • <% end %>

request.env

    <% request.env.keys.each do |key| %>
  • request.env['<%= key %>'] = <%= request.env[key] %>
  • <% end %>

That should give you a list of everything currently available. Note
that I originally forgot about ‘request.env’ which provides some more
info.


http://www.5valleys.com/