Plz test my patch for resources with path_prefix with a variable


The problem:
You may have read the I18n-Guide (
Rails Internationalization (I18n) API — Ruby on Rails Guides).
It says, that the usual way to provide the locale is in the URL, like But:

map.resources :books, :path_prefix => ‘/:locale’


This solution has currently one rather big downside. Due to the
default_url_options implementation, you have to pass the :id option
explicitely, like this: link_to ‘Show’, book_url(:id => book) and not
depend on Rails’ magic in code like link_to ‘Show’, book.

Actually this is not a problem of default_url_options, but of
polymorphic_url, which is utilized by link_to in the example. It
the book_url and passes an array into the generated route. This array
only one item, the book id. book_url tries to fill in the id into the
parameter of the url, which is the locale (/:locale/books/:id), which
the :id unsatisfied, raising an exception.

The solution:
With my patch, polymorphic_url will pass an hash instead of an array to
generated route. It may look like {:id => 2}. It works also with nested
resources: e.g.: {:author_id => 3, :id => 2}

The patch:
I’ve created a patch for Rails 3 and Rails 2-3-stable and put them in a
ticked on lighthouse:

I hope, you’ll find this patch useful and it gets accepted into rails

Regards from Hamburg, Germany


Hi friends,

How to increase the response speed rails application. Pls suggest some
to improve the performance.