Forum: Ruby on Rails How can I get the current path which is processed by rails?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1292dfc5df2064e008f7f12b9c56561d?d=identicon&s=25 allen (Guest)
on 2007-07-03 08:51
(Received via mailing list)
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
3299251223f55753ec84719de39e6e53?d=identicon&s=25 Jon Garvin (Guest)
on 2007-07-03 16:45
(Received via mailing list)
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/
744b6438d1457d332d1a8d431cc2b641?d=identicon&s=25 andrew.ohnstad@gmail.com (Guest)
on 2007-07-03 17:05
(Received via mailing list)
Is there a list anywhere of what all is usually in ENV?

Thanks!
3299251223f55753ec84719de39e6e53?d=identicon&s=25 Jon Garvin (Guest)
on 2007-07-03 17:24
(Received via mailing list)
andrew.ohnstad@gmail.com 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
<ul>
<% ENV.keys.each do |key| %>
   <li>ENV['<%= key %>'] = <%= ENV[key] %></li>
<% end %>
</ul>

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

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/
This topic is locked and can not be replied to.