Setting variable via url

Hi all,

One of my routes looks like this: map.connect
‘:blog/:controller/:action/:id’

The :blog should actualy become a session variable (indication who’s
blog it is). eg url: www.site.com/railsblog/posts/ I want to set a
session variable to ‘railsblog’. Is this possible? If yes, how do I do
this?

Thanks in advance
Stijn

In your example, params[:blog] has the value ‘railsblog’, so you
could do session[:blog] = params[:blog] to set a session variable
with that value.


Building an e-commerce site with Rails?
http://agilewebdevelopment.com/rails-ecommerce

Meet up at RailsConf:
http://railsconf2007.conferencemeetup.com/

With every request I should set that blog parameter to the session
variable. I tried to add session[:blog] = params[:blog] in the
ApplicationController but this doesn’t work (‘We’re sorry, but
something went wrong.’). Isn’t the AppliationController always called
and isn’t it thus the perfect place to set that session variable?

Thanks in advance
Stijn

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