Reading from Session in routes.rb?

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? :slight_smile:

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