Forum: Ruby on Rails Reading from Session in routes.rb?

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.
D. Taylor S. (Guest)
on 2006-03-04 23:17
(Received via mailing list)
Hi all,

I'm developing some custom routes for an application and am creating the
aliased url_for commands that I like so much. However, one of the things
I'd
like to do is read a string from the session (or possibly even pull out
an
object to get to the string) and use that in the URL generating by the
route
-- without having to pass the string into the url_for alias every time.
After attempting to access the session method and session class variable
in
routes.rb to ill effect (you just can't) and also trying to run a
breakpoint
in routes.rb (which also doesn't seem to work quite right) -- I can't
quite
figure out what information is available to the app at that stage.
Looking
through the API docs and Routing how-tos, I've found nothing that sheds
any
light at this aspect of routes.rb.

So, has anyone had any success with this? Is it possible to override
your
aliased url_for method to automatically grab the "label" from the
session
and put into the default arguments for the url_for alias? If so, where
would
I put that-- in the application helper? (doesn't quite seem right)..

Did this make sense or do I need to restate my problem? :)

I want a route -- :label/:controller/:action/:id -- where :label comes
automatically from the session.

Thank you for any help in this direction.

D. Taylor S.,
Reality Technician
This topic is locked and can not be replied to.