Trouble Upgrading Rails 2 Routes for a Redmine Plugin
- by user1858628
I am trying to get a Redmine plugin designed for Rails 2 to work with Rails 3.
https://github.com/dalyons/redmine-todos-scrum-plugin
I've pretty much fixed most parts, but having no success whatsoever in getting the routes to work.
The original routes for Rails 2 are as follows:
map.resources :todos, :name_prefix => 'project_', :path_prefix => '/projects/:project_id',
:member => {:toggle_complete => :post }, :collection => {:sort => :post}
map.resources :todos, :name_prefix => 'user_', :path_prefix => '/users/:user_id', :controller => :mytodos,
:member => {:toggle_complete => :post }, :collection => {:sort => :post}
map.my_todos 'my/todos', :controller => :mytodos, :action => :index
map.connect 'projects/:project_id/todos/show/:id', :controller => "todos", :action => "show"
rake routes outputs the following:
sort_project_todos POST /projects/:project_id/todos/sort(.:format) {:controller=>"todos", :action=>"sort"}
project_todos GET /projects/:project_id/todos(.:format) {:controller=>"todos", :action=>"index"}
POST /projects/:project_id/todos(.:format) {:controller=>"todos", :action=>"create"}
new_project_todo GET /projects/:project_id/todos/new(.:format) {:controller=>"todos", :action=>"new"}
toggle_complete_project_todo POST /projects/:project_id/todos/:id/toggle_complete(.:format) {:controller=>"todos", :action=>"toggle_complete"}
edit_project_todo GET /projects/:project_id/todos/:id/edit(.:format) {:controller=>"todos", :action=>"edit"}
project_todo GET /projects/:project_id/todos/:id(.:format) {:controller=>"todos", :action=>"show"}
PUT /projects/:project_id/todos/:id(.:format) {:controller=>"todos", :action=>"update"}
DELETE /projects/:project_id/todos/:id(.:format) {:controller=>"todos", :action=>"destroy"}
sort_user_todos POST /users/:user_id/todos/sort(.:format) {:controller=>"mytodos", :action=>"sort"}
user_todos GET /users/:user_id/todos(.:format) {:controller=>"mytodos", :action=>"index"}
POST /users/:user_id/todos(.:format) {:controller=>"mytodos", :action=>"create"}
new_user_todo GET /users/:user_id/todos/new(.:format) {:controller=>"mytodos", :action=>"new"}
toggle_complete_user_todo POST /users/:user_id/todos/:id/toggle_complete(.:format) {:controller=>"mytodos", :action=>"toggle_complete"}
edit_user_todo GET /users/:user_id/todos/:id/edit(.:format) {:controller=>"mytodos", :action=>"edit"}
user_todo GET /users/:user_id/todos/:id(.:format) {:controller=>"mytodos", :action=>"show"}
PUT /users/:user_id/todos/:id(.:format) {:controller=>"mytodos", :action=>"update"}
DELETE /users/:user_id/todos/:id(.:format) {:controller=>"mytodos", :action=>"destroy"}
my_todos /my/todos {:controller=>"mytodos", :action=>"index"}
/projects/:project_id/todos/show/:id {:controller=>"todos", :action=>"show"}
The nearest I have got for Rails 3 is follows:
scope '/projects/:project_id', :name_prefix => 'project_' do
resources :todos, :controller => 'todos' do
member do
post :toggle_complete
end
collection do
post :sort
end
end
end
scope '/users/:user_id', :name_prefix => 'user_' do
resources :todos, :controller => 'mytodos' do
member do
post :toggle_complete
end
collection do
post :sort
end
end
end
match 'my/todos' => 'mytodos#index', :as => :my_todos
match 'projects/:project_id/todos/show/:id' => 'todos#show'
rake routes outputs the following:
toggle_complete_todo POST /projects/:project_id/todos/:id/toggle_complete(.:format) todos#toggle_complete {:name_prefix=>"project_"}
sort_todos POST /projects/:project_id/todos/sort(.:format) todos#sort {:name_prefix=>"project_"}
todos GET /projects/:project_id/todos(.:format) todos#index {:name_prefix=>"project_"}
POST /projects/:project_id/todos(.:format) todos#create {:name_prefix=>"project_"}
new_todo GET /projects/:project_id/todos/new(.:format) todos#new {:name_prefix=>"project_"}
edit_todo GET /projects/:project_id/todos/:id/edit(.:format) todos#edit {:name_prefix=>"project_"}
todo GET /projects/:project_id/todos/:id(.:format) todos#show {:name_prefix=>"project_"}
PUT /projects/:project_id/todos/:id(.:format) todos#update {:name_prefix=>"project_"}
DELETE /projects/:project_id/todos/:id(.:format) todos#destroy {:name_prefix=>"project_"}
POST /users/:user_id/todos/:id/toggle_complete(.:format) mytodos#toggle_complete {:name_prefix=>"user_"}
POST /users/:user_id/todos/sort(.:format) mytodos#sort {:name_prefix=>"user_"}
GET /users/:user_id/todos(.:format) mytodos#index {:name_prefix=>"user_"}
POST /users/:user_id/todos(.:format) mytodos#create {:name_prefix=>"user_"}
GET /users/:user_id/todos/new(.:format) mytodos#new {:name_prefix=>"user_"}
GET /users/:user_id/todos/:id/edit(.:format) mytodos#edit {:name_prefix=>"user_"}
GET /users/:user_id/todos/:id(.:format) mytodos#show {:name_prefix=>"user_"}
PUT /users/:user_id/todos/:id(.:format) mytodos#update {:name_prefix=>"user_"}
DELETE /users/:user_id/todos/:id(.:format) mytodos#destroy {:name_prefix=>"user_"}
my_todos /my/todos(.:format) mytodos#index
/projects/:project_id/todos/show/:id(.:format) todos#show
I am guessing that I am not using :name_prefix correctly, resulting in duplicate paths which are then omitted.
Any help would be greatly appreciated.