Skip to content

Instantly share code, notes, and snippets.

@adamdilek
Created February 11, 2014 11:23
Show Gist options
  • Select an option

  • Save adamdilek/8933119 to your computer and use it in GitHub Desktop.

Select an option

Save adamdilek/8933119 to your computer and use it in GitHub Desktop.
Rails locale url and to_param
#routes
namespace :hq do
scope "(:locale)", :locale => /en|tr|ru/ do
resources :pages
end
end
#Page model
def to_param
"#{id}-#{title.present? ? title.parameterize : ''}"
end
#Application Controller
protect_from_forgery
def default_url_options(options={})
{ :locale => I18n.locale }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment