Change session variable and reload page

This is my first post and I'm sure the question is noobish but I swear I've googled intensively and couldn't find a smart solution to my problem:

I'm developing a webapp in wich you will be able to set the language of it's layout by clicking on a link. The name of the language will be stored in a session variable, so what this link has to do is 1st change that session variable and 2nd, reload the page you are in.

Since you'll be able to do this in any page of the webapp, I thought I would place the setter and getter to the variable in the Application controller like this:

class ApplicationController < ActionController::Base   helper :all

  protected   def application_language     session[:application_language]   end

  protected   def application_language=(language)     session[:application_language] = language   end end

and now I just need to come up with a helper that will let me access this functions and reload the page. something like a link_to. Can someone help me?

Thanks.

Abel wrote:

This is my first post and I'm sure the question is noobish but I swear I've googled intensively and couldn't find a smart solution to my problem:

I'm developing a webapp in wich you will be able to set the language of it's layout by clicking on a link. The name of the language will be stored in a session variable, so what this link has to do is 1st change that session variable and 2nd, reload the page you are in.

Since you'll be able to do this in any page of the webapp, I thought I would place the setter and getter to the variable in the Application controller like this:

class ApplicationController < ActionController::Base   helper :all

  protected   def application_language     session[:application_language]   end

  protected   def application_language=(language)     session[:application_language] = language   end end

and now I just need to come up with a helper that will let me access this functions and reload the page. something like a link_to. Can someone help me?

Thanks.

Sounds like you're just asking for a refresh of the current page with a different parameter( the language).

If you're currently on the index page for, oh, Star Trek Episodes, then maybe:

<%= link_to 'See this in Klingon', episodes_path(:language => 'klingon') %>

In the episodes controller, you could code something like

def index   if params[:language]     application_language = params[:language]   end   ... your other index code here... end

Thanks, Ar. Now I feel embarrassed how easy it was. I guess I will place that code in a filter so the language can be chosen from any action in the application.