2011-05-26 98 views
0

有沒有更好的方法來寫在軌道3這樣的路線? 我將我的應用程序從導軌2轉換爲導軌3。寧靜的路線?

匹配 「/恢復/教育/ edit_education」, :控制器=> 「簡歷/教育#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

我想你應該重構你的控制器一樣這

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 

看指導Rails Routing from the Outside In