Hello, there: I wish A link to invoke such a action together with the parameter "zh_CN" "cookies/switch_language/zh_CH" to switch language sellection, and I use the following code: <%= link_to ''Chinese'', :controller => ''cookies'', :action => ''switch_lang'' %> But, how is "link_to" able to convey the params: zh_CN as well? seems like link_to doesn''t support a option :params => ''zh_CN''.....because it errors when I use ''<%= link_to ''Chinese'', :controller => ''cookies'', :action => ''switch_lang/zh_CN'' %> & <%= link_to ''Chinese'', :controller => ''cookies'', :action => ''switch_lang'', params: => ''zh_CN '' %> Thanks in advance! Myst --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Hello, there: > I wish A link to invoke such a action together with the parameter > "zh_CN" "cookies/switch_language/zh_CH" to switch language > sellection, and I use the following code: > <%= link_to ''Chinese'', :controller => ''cookies'', :action => > ''switch_lang'' %> > > But, how is "link_to" able to convey the params: zh_CN as well? > seems like link_to doesn''t support a option :params => > ''zh_CN''.....because it errors when I use > ''<%= link_to ''Chinese'', :controller => ''cookies'', :action => > ''switch_lang/zh_CN'' %> & > <%= link_to ''Chinese'', :controller => ''cookies'', :action => > ''switch_lang'', params: => ''zh_CN '' %>Assuming you still have the default route installed use this: <%= link_to ''Chinese'', :controller => ''cookies'', :action => ''switch_lang'', :id => ''zh_CN'' %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You could also use a custom route so you can use the symbol of your choosing and assemble the URL however you want. Something like.... <%= link_to ''Chinese'', :controller => ''cookies'', :action => ''switch_lang'', :lang => ''zh_CN'' %> ..and.. map.connect ''foo/:lang'', :controller => ''cookies'', :action => ''switch_lang'' Preston -- PrestonLee.com OpenRain, LLC On Jan 3, 2008, at 6:52 PM, Philip Hallstrom wrote:> <%= link_to ''Chinese'', :controller => ''cookies'', > :action => ''switch_lang'', > :id => ''zh_CN'' %>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Cool, thank you both! On 1月4日, 上午1时11分, myst_tt <tdxia...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, there: > I wish A link to invoke such a action together with the parameter > "zh_CN" "cookies/switch_language/zh_CH" to switch language > sellection, and I use the following code: > <%= link_to ''Chinese'', :controller => ''cookies'', :action => > ''switch_lang'' %> > > But, how is "link_to" able to convey the params: zh_CN as well? > seems like link_to doesn''t support a option :params => > ''zh_CN''.....because it errors when I use > ''<%= link_to ''Chinese'', :controller => ''cookies'', :action => > ''switch_lang/zh_CN'' %> & > <%= link_to ''Chinese'', :controller => ''cookies'', :action => > ''switch_lang'', params: => ''zh_CN '' %> > > Thanks in advance! > Myst--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---