restful way of routes?
Is there a better way to write such routs in rails 3 ? I converted my application from rails 2 to rails 3 .
match "/resume/education/edit_education", :controller => "resume/edu开发者_JAVA百科cation#edit_education", :as=>"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"
I think you should refactor your controller like this
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
Then you could organize your routes thus
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
Look to guide Rails Routing from the Outside In
精彩评论