有没有更好的方法在rails 3中编写这样的路径? 我将我的应用程序从rails 2转换为rails 3。
匹配“/ resume / education / edit_education”, :controller => “简历/教育#edit_education” :如=> “中resume_edit_education”
match "/resume/education/update_education",
:controller => "resume/education#update_education",
:as=>"resume_update_education"
match "/resume/education/cancel_education_add",
:controller => "resume/education#cancel_education_add",
:as=>"resume_cancel_education_add"
match "/resume/education/cancel_education_edit",
:controller => "resume/education#cancel_education_edit",
:as=>"resume_cancel_education_edit"
match "/resume/education/remove_education",
:controller => "resume/education#remove_education",
:as=>"resume_remove_education"
match "/resume/education/update_education_title",
:controller => "resume/education#update_education_title",
:as=>"resume_update_education_title"
match "/resume/education/move_up",
:controller => "resume/education#move_up",
:as=>"resume_education_move_up"
match "/resume/education/move_down",
:controller => "resume/education#move_down",
:as=>"resume_education_move_down"
match "/resume/education/remove",
:controller => "resume/education#remove",
:as=>"resume_remove_education"
答案 0 :(得分:0)
我认为你应该像这样重构你的控制器
class Resume::EducationController
def cancel_add
end
def cancel_edit
end
def update_title
end
def move_up
end
def move_down
end
def update
end
def destroy
end
end
然后你可以组织你的路线
namespace :resume do
resource :education, :only => [:update, :destroy] do
collection do
get 'cancel_add'
get 'cancel_update'
get 'update_title'
get 'move_up' # get -> put ?
get 'move_down'
end
end
end