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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Mar 21, 9:51 pm, Ar Chron <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---