Skip to content

Instantly share code, notes, and snippets.

View remi-duvergey's full-sized avatar

Rémi Duvergey remi-duvergey

  • Sentient Technologies
  • San Francisco
View GitHub Profile
@henrik
henrik / patch_rails_i18n_routing_positional_arguments.rb
Created March 20, 2012 14:52
Allow foo_path(foo) even with :locale prefix in routes in Rails 3.
unless Rails::VERSION::STRING == "3.2.2"
raise "Rails version changed. Revisit overrides and make sure they're still good!"
end
# If routes are prefixed with a :locale, you can no longer do
# `foo_path(foo)` but only `foo_path(id: foo)`, since it expects
# the first of any non-hash arguments to be the locale.
# This monkeypatch fixes that by never allowing locale as the first
# non-hash argument, and instead always setting current locale as a
# hash option.