Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

before_filter set_locale except controller

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!

like image 882
hyperrjas Avatar asked Feb 01 '26 22:02

hyperrjas


1 Answers

Use skip_before_filter in your Blog controllers?

like image 199
sevenseacat Avatar answered Feb 03 '26 12:02

sevenseacat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!