红宝石铁轨3-宁静的路线



有更好的方法在rails 3中编写这样的路由吗?我将应用程序从rails 2转换为rails 3。

匹配"/resume/education/edit_education",:controller=>"简历/教育#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"

我认为你应该像这个一样重构你的控制器

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

在中从外部寻找导轨布线

相关内容

  • 没有找到相关文章

最新更新