Forum: Ruby on Rails trying to have pretty localized root url

Posted by Kad Kerforn (kadoudal)
on 2012-11-16 16:15
(Received via mailing list)
I have a language scope in my routes, all urls looking good
 www.lvh.me/en/[*path....]

with the exception of the root_url   displayed as :
 http://www.lvh.me/?locale=en

I am trying for a couple of hours to get a root url being :
 http://www.lvh.me/en/  as I get with the initial constraint when no
subdomain given, but no way , everytime I use  redirect_to root_url , I 
get
this http://www.lvh.me/?locale=en

the default_url_options seems not to be used , as I try to have a debug
line in it .. no way

  def default_url_options(options={})
    if request.fullpath == "/"
      {}
    else
      { :locale => I18n.locale }
    end
  end



__________

  scope "/:locale" do
    ... ....
  end
    constraints(:subdomain => nil, :host => host) do
    root :to => 
redirect("http://www.#{host}#{port}/#{I18n.locale.to_s}/")
    match '/*path', :to => redirect {|params|
"http://www.#{host}#{port}/#{I18n.locale.to_s}/#{pa...
  end

  root :to => "cms_content#render_html"
Posted by Kad Kerforn (kadoudal)
on 2012-11-16 17:13
(Received via mailing list)
[SOLVED]  as I am using Sofa CMS for rendering, I have to replace
redirect_to root_url with a redirection to the home page of the CMS...

redirect_to "/#{I18n.locale}#{@cms_site.pages.root.full_path}"

Le vendredi 16 novembre 2012 16:14:25 UTC+1, Erwin a crit :
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.