title: locale prefix in url
body: <p>In my Rail 3.0.9 app I have routes.rb:</p>
  
  <pre><code>Myapp::Application.routes.draw do
    root :to =&gt; 'index#index'
    match '/:locale' =&gt; 'index#index', :locale =&gt; /ru|en/
    scope "(:locale)", :locale =&gt; /ru|en/ do
      resources :pages, :only =&gt; [:show]
  ...
  </code></pre>
  
  <p>When going to / path in browser, 404 error is shown and message in logs:</p>
  
  <pre><code>Started GET "/" for 127.0.0.1 at Tue Sep 06 12:45:18 +0400 2011
    Processing by IndexController#index as HTML
  Creating scope :limit. Overwriting existing method NewsItem.limit.
    ESC[1mESC[35mNewsItem Load (0.2ms)ESC[0m  SELECT `news_items`.* FROM `news_items` WHERE (category = 'events') ORDER BY published_at DESC
  Rendered layouts/_mini_calendar.erb (29.5ms)
    ESC[1mESC[36mSQL (0.2ms)ESC[0m  ESC[1mSELECT COUNT(*) FROM `news_items` WHERE (category = 'events') AND (published_at BETWEEN '2010-12-31 21:00:00' AND '2011-01-01 20:59:59')ESC[0m
    ESC[1mESC[35mSQL (0.2ms)ESC[0m  SELECT COUNT(*) FROM `news_items` WHERE (category = 'events') AND (published_at BETWEEN '2010-12-31 21:00:00' AND '2011-01-31 20:59:59')
    ESC[1mESC[36mNewsItem Load (0.2ms)ESC[0m  ESC[1mSELECT `news_items`.* FROM `news_items` WHERE (category = 'events') ORDER BY published_at DESC LIMIT 3ESC[0m
  Rendered index/index.html.erb within layouts/static (212.4ms)
  Completed 500 Internal Server Error in 220ms
  No route matches {:locale=&gt;#&lt;NewsItem id: 20, title_ru: "event 2", description_ru: "&lt;p&gt;event description&lt;/p&gt;", published_at: "2011-08-31 07:55:00", category: "events", created_at: "2011-08-31 07:55:26", updated_at: "2011-08-31 07:55:26", short_description_ru: "&lt;p&gt;descr&lt;/p&gt;", title_en: nil, description_en: nil, short_description_en: nil&gt;, :action=&gt;"show", :controller=&gt;"news_items"}
  Rendered layouts/_head_static.erb (2.3ms)
  Rendered layouts/_ga.erb (0.3ms)
  Rendered layouts/_logo.erb (1.0ms)
  Rendered layouts/_copiny_widget.erb (0.3ms)
  Rendered errors/404.html.erb within layouts/error (10.6ms)
  </code></pre>
  
  <p>It tries to get make strange link</p>
  
  <pre><code>No route matches {:locale=&gt;#&lt;NewsItem id: 20, title_ru: "event 2", description_ru: "&lt;p&gt;event description&lt;/p&gt;", published_at: "2011-08-31 07:55:00", category: "events", created_at: "2011-08-31 07:55:26", updated_at: "2011-08-31 07:55:26", short_description_ru: "&lt;p&gt;descr&lt;/p&gt;", title_en: nil, description_en: nil, short_description_en: nil&gt;, :action=&gt;"show", :controller=&gt;"news_items"}
  </code></pre>
  
  <p>Problem is in line</p>
  
  <pre><code>&lt;%= link_to l(news_item.published_at, :format =&gt; "%d.%m.%Y"), news_item %&gt;
  </code></pre>
  
  <p>When I change it to</p>
  
  <pre><code>&lt;%= link_to l(news_item.published_at, :format =&gt; "%d.%m.%Y"), :url =&gt; news_item %&gt;
  </code></pre>
  
  <p>problem is solved.</p>
  
  <p>1) Why news_item in first line is interpreted as :locale, not :url?</p>
  
  <p>2) Is this a bug or maybe I miss something?</p>
  
  <p>Thanks to all!</p>
  
  <p>Finally I found the best solution:</p>
  
  <pre><code>def set_locale
    ...
    self.default_url_options[:locale] = params[:locale]
  end
  </code></pre>