2

I'm migrating an application from Rails 2.3.5 to Rails 3.2.8. I have this route from the Rails 2 app that is giving me headaches:

  map.resources :soumission_vt,
                :path_prefix => "/soumission/VT/:page_id", :as => 'police/:action/:id',
                :requirements => {:page_id => /\S+/}

wich generates the following:

soumission_vt_index GET    /soumission/VT/:page_id/police/:action/:id(.:format)               {:controller=>"soumission_vt"}
                    POST   /soumission/VT/:page_id/police/:action/:id(.:format)               {:controller=>"soumission_vt"}
new_soumission_vt   GET    /soumission/VT/:page_id/police/:action/:id/new(.:format)           {:controller=>"soumission_vt"}
edit_soumission_vt  GET    /soumission/VT/:page_id/police/:action/:id/:id/edit(.:format)      {:controller=>"soumission_vt"}
soumission_vt       GET    /soumission/VT/:page_id/police/:action/:id/:id(.:format)           {:controller=>"soumission_vt"}
                                    PUT    /soumission/VT/:page_id/police/:action/:id/:id(.:format)           {:controller=>"soumission_vt"}
                    DELETE /soumission/VT/:page_id/police/:action/:id/:id(.:format)           {:controller=>"soumission_vt"}

I translated it this way in Rails 3:

  scope '/soumission/VT/:page_id', :constraints => {:page_id => /\S+/} do
    resources :soumission_vt, :as => 'police/:action/:id'
  end

but I am getting an Invalid route name: 'police/:action/:id_index'...

So is there a way to reproduce those routes in Rails 3?

Thanks!

Sam Mussmann
  • 5,883
  • 2
  • 29
  • 43

1 Answers1

1

After one try, I succeeded to make it work with the following lines of code:

scope '/soumission/VT/:page_id' do
    get 'police/new', controller: :soumission_vt, action: :new, as: :new_soumission_vt
end

Hope this will help you finish your migration in time !

;)