My routes.rb
MyApp::Application.routes.draw do
scope '(:locale)' do
#all resources here
end
namespace :blog do
resources :posts, :only => [:index, :show]
end
end
My application_controller.rb
class ApplicationController < ActionController::Base
#
#
before_filter :set_locale
private
def default_url_options(options = {})
{locale: I18n.locale}
end
def set_locale
#code for detect locale here
end
#
#
end
All the resources inside scope '(:locale)' is working fine.
However I don't want use locale with namespace :blog and when I try click on blog links I can see this url http://localhost:3000/blog/posts?locale=en
How can I remove locale of namespace :blog... and blog resource?. I want get a url something like http://localhost:3000/blog/posts I want to remove the ?locale=en
Thanks!
Use skip_before_filter in your Blog controllers?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With