Featured post
localization - What's the proper way to handle localized name-spaced routes in Rails 2.3.8? -
i'm localizing application , struggling how handle routes specific portion of app.
initially had routes looked this:
map.namespace :admin |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
from i've done on other routes need add: :path_prefix => '/:locale/'
these routes.
the example i've come across looks this:
map.with_options(:path_prefix => '/:locale/admin') |locale| locale.namespace :admin |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
this appears works great routes, however, screwing of generated urls.
for example had = link_to(t('subscription'), edit_admin_subscription_path(subscription_id)
worked perfectly... after above change url no longer generates, giving following error:
actioncontroller::routingerror in admin/base#index showing app/views/admin/shared/_menu.html.haml line #13 raised: edit_admin_subscription_url failed generate {:action=>"edit", :controller=>"admin/subscriptions", :locale=>bson::objectid('4d0ecb6587adddc91c000014')}, expected: {:controller=>"admin/subscriptions", :action=>"edit"}, diff: {:locale=>bson::objectid('4d0ecb6587adddc91c000014')}
i sincerely appreciate insight can shed on proper way handle type of thing and/or why url doesn't generate longer. thanks!
so turns out after addition of localization, needed more specific the parameters passed url helper:
= link_to(t('subscription'), edit_admin_subscription_path(:id => subscription_id)
works fine.
still not sure not if the
map.with_options(:path_prefix => '/:locale/admin') |locale| locale.namespace :admin |admin|
is best way that, @ least it's working now.
- Get link
- X
- Other Apps
Comments
Post a Comment