Ruby on rails Rails 3中的布线(从Rails 2升级)

Ruby on rails Rails 3中的布线(从Rails 2升级),ruby-on-rails,Ruby On Rails,您好,上面的代码是Rails 2中编写的routes代码的一部分。我无法将这段代码转换为Rails3的等效代码。如果有人能指导我解决这个问题,我会很高兴。谢谢。应该是这样的: map.resources :users, :collection => {:access_history => :get }, :member => {:change_access => :any } 有关Rails 3中布线的更多信息

您好,上面的代码是Rails 2中编写的routes代码的一部分。我无法将这段代码转换为Rails3的等效代码。如果有人能指导我解决这个问题,我会很高兴。谢谢。

应该是这样的:

map.resources :users, 
              :collection => {:access_history => :get }, 
              :member => {:change_access => :any }
有关Rails 3中布线的更多信息,请查看。

较短版本:

resources :users do
  collection do
    get :access_history
  end

  member do
    match :change_access
  end
end
 resources :users do
      get 'access_history', :on => :collection
      match 'change_access', :on => :member
 end