Open acenqiu opened 11 years ago
Still has not been updated. I am having the same problem. I get the error below when I try to launch my Rails application.
cannot load such file -- routing_filter/adapters/rails_4
I have published https://rubygems.org/gems/routing-filter/versions/0.4.0.pre. Please check if it works well.
I have finally had a chance to use the 0.4.0.pre version of the gem for Rails 4. However I am finding differences between this version and the one I currently use in my Rails 3 applications. I'm not sure if there are differences in the routing-filter gems or if the issue is with i18n changes in Rails 4.
Here is the code I have in both applications in application_controller.rb where I set the locale and create a cookie.
before_filter :set_locale
private def set_locale I18n.locale = (params[:locale] if params[:locale].present?) || cookies[:locale] || 'en' cookies[:locale] = I18n.locale if cookies[:locale] != I18n.locale.to_s end
Here is the code I have in config/routes.rb.
filter :locale
When I run my Rails 3 applications the locale appears in the URL link and my debug info when I click all my links. When I run my Rails 4 application the only time the locale appears in the link is when I click a link to set the locale. When I click all my other links (text or icon) the translations appear correctly but there is not a locale value in the URL or in the debug info.
Here is the code for my locale line in my header.
<%= link_to_unless_current "English", locale: "en" %> <%= link_to_unless_current "Español", locale: "es" %> <%= link_to_unless_current "Français", locale: "fr" %>
Again I'm not sure if the issue is with the 0.4.0.pre gem or if I need to make additional i18n changes in my Rails 4 application. From reading the i18n documentation I'm not seeing anything additional I need to do. There is no specific documentation about 0.4.0.pre so I assume I should be able to do what I am doing with the Rails 3 version of routing-filter.
Any help would be appreciated.
The routes still do not include the locale like the Rails 3 version did.
Anything about this?
I removed the gem since I could not get it working the way it did in Rails 3. The last I checked it is still a prerelease version. I am using the built in Rails 4 i18n functionality. I was able to get the routing I wanted with the locale in the route e.g. /en. I'm also have code where the locale defaults to en if it is missing from the route.
The gem hosted in rubygems is still an old version, which is incompatible with Rails 4.