以下是redmine 的 todos 插件的路线,但它采用 rails 2 方式
map.resources :todos, :name_prefix => 'project_', :path_prefix => '/projects/:project_id',
:member => {:toggle_complete => :post }, :collection => {:sort => :post}
map.with_options :controller => 'mytodos' do |mytodos_routes|
mytodos_routes.new_personal_todo 'mytodos/:parent_id/new', :action => 'new'
mytodos_routes.connect 'mytodos/:parent_id/new.:format', :action => 'new'
end
请帮我以rails 3方式转换它。
谢谢。
编辑:这是我所做的,但不知道天气是否正确
RedmineApp::Application.routes.draw do
scope ':project_id' do
resources :todos, :name_prefix => 'project_' do
member do
post :toggle_complete
end
collection do
post :sort
end
end
end
scope ':user_id' do
resources :todos, :name_prefix => 'user_' do
member do
post :toggle_complete
end
collection do
post :sort
end
end
end
match 'mytodos/index',:to => 'mytodos#index', :via => 'get'