Created
February 11, 2014 11:23
-
-
Save adamdilek/8933119 to your computer and use it in GitHub Desktop.
Rails locale url and to_param
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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