Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's the proper way to handle localized name-spaced routes in Rails 2.3.8?
    primarykey
    data
    text
    <p>I'm localizing my application and am struggling with how to handle routes for a specific portion of the app.</p> <p>Initially I had routes that looked like this:</p> <pre><code> map.namespace :admin do |admin| admin.resources :people, :member => {:confirm_destroy => :get}, :collection => {:follow => :post, :sync_friends => :get, :upload => :post, :import => :get, :recommendations => :get, :mark_recommendations => :post, :batch_create => :post} admin.resources :jobs, :collection => {:remove => :post} admin.resources :users, :member => {:confirm_destroy => :get} admin.resources :sites, :member => {:update_design => :post, :design => :get, :update_links => :post, :links => :get, :content => :get, :update_content => :post, :add_admin => :post, :remove_admin => :post, :set_system_account => :get, :confirm_system_account => :get}, :collection => {:remove => :post, :upload => :post} admin.resources :subscriptions, :member => { :charge => :post, :migrate_plan => :post, :update_components => :post } admin.resources :accounts, :collection => {:remove => :post} admin.resources :subscription_plans, :as => 'plans' admin.resources :subscription_discounts, :as => 'discounts' admin.resources :twitter_lists, :collection => {:auto_generate_twitter_list => :post} end </code></pre> <p>From what I've done successfully on other routes I need to add: <code>:path_prefix => '/:locale/'</code> to these routes.</p> <p>The only example I've come across looks something like this: <br><br> <code><pre> map.with_options(:path_prefix => '/:locale/admin') do |locale| locale.namespace :admin do |admin| admin.resources :people, :member => {:confirm_destroy => :get}, :collection => {:follow => :post, :sync_friends => :get, :upload => :post, :import => :get, :recommendations => :get, :mark_recommendations => :post, :batch_create => :post} admin.resources :subscriptions, :member => { :charge => :post, :migrate_plan => :post, :update_components => :post } admin.resources :accounts, :collection => {:remove => :post} etc etc etc end end </code></pre></p> <p>This actually appears works great for the routes, however, it is screwing up some of my generated URLS.</p> <p>For example previously I had something like <code>= link_to(t('subscription'), edit_admin_subscription_path(subscription_id)</code> which worked perfectly... after the above change this url no longer properly generates, giving the following error:<br><br></p> <pre> ActionController::RoutingError in Admin/base#index Showing app/views/admin/shared/_menu.html.haml where line #13 raised: edit_admin_subscription_url failed to generate from {:action=>"edit", :controller=>"admin/subscriptions", :locale=>BSON::ObjectId('4d0ecb6587adddc91c000014')}, expected: {:controller=>"admin/subscriptions", :action=>"edit"}, diff: {:locale=>BSON::ObjectId('4d0ecb6587adddc91c000014')} </pre> <p><strong>I would sincerely appreciate any insight anyone can shed on the proper way to handle this type of thing and/or why this url doesn't like to generate any longer. THANKS!</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload