Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix Rails3 bug with named routes and prefix path - Bump to 0.4.1

  • Loading branch information...
commit 2c70e5dfe9dcf8c8b8130367c5210a0fb36832f9 1 parent b0ffa90
Guillaume kwi authored
4 CHANGELOG.rdoc
View
@@ -1,3 +1,7 @@
+0.4.1 (September 11, 2010)
+
+* Fix a Rails3 bug for named routes and prefixed path
+
0.4.0 (September 08, 2010)
* Full support for Rails 3.0.0
2  i18n_routing.gemspec
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "i18n_routing"
- s.version = "0.4.0"
+ s.version = "0.4.1"
s.author = "Guillaume Luccisano"
s.email = "guillaume.luccisano@gmail.com"
s.homepage = "http://github.com/kwi/i18n_routing"
2  lib/i18n_routing_rails3.rb
View
@@ -290,7 +290,7 @@ def initialize(locale, set, scope, path, options)
I18n.locale = locale
ts = @path.gsub(/^\//, '')
ts.gsub!('(.:format)', '')
- @localized_path = '/' + (I18nRouting.translation_for(ts, :named_routes_path) || ts)
+ @localized_path = (@scope[:path] || '/') + (!ts.blank? ? (I18nRouting.translation_for(ts, :named_routes_path) || ts) : '')
# If a translated path exists, set localized infos
if @localized_path and @localized_path != @path
17 spec/i18n_routing/i18n_spec.rb
View
@@ -16,10 +16,10 @@
map.localized(I18n.available_locales, :verbose => false) do
map.about 'about', :controller => 'about', :action => :show
-
+
map.resources :users, :member => {:level => :get}, :collection => {:groups => :get}
map.resource :contact
-
+
map.resources :authors do |m|
m.resources :books
end
@@ -30,7 +30,7 @@
mm.resources :bars
end
end
-
+
map.resources :universes do |m|
m.resources :galaxies do |mm|
mm.resources :planets do |mmm|
@@ -38,7 +38,8 @@
end
end
end
-
+
+ map.localized_root '/', :controller => "about", :action => "show", :path_prefix => ':locale'
map.resources :drones, :path_prefix => 'doubledrones/unimatrix/zero'
end
end
@@ -60,6 +61,10 @@ class UrlTester
localized(I18n.available_locales, :verbose => false) do
match 'about' => "about#show", :as => :about
+ scope '/:locale', :constraints => { :locale => /[a-z]{2}/ } do
+ match '/' => "about#show", :as => :localized_root
+ end
+
resources :users do
member do
get :level
@@ -166,6 +171,10 @@ def url_for(opts)
before do
I18n.locale = :fr
end
+
+ it "scope with parameters should be respected" do
+ routes.send(:localized_root_path, I18n.locale).should == "/#{I18n.locale}"
+ end
it "named_route generates route using localized values" do
routes.send(:about_path).should == "/#{I18n.t :about, :scope => :named_routes_path}"
Please sign in to comment.
Something went wrong with that request. Please try again.