如何为get和post制作路线?

时间:2011-03-16 03:47:57

标签: ruby-on-rails

我有这个:

resources :users do

  collection do


  get 'blah'

  end

end

我想对这两个帖子做出这个动作(等等),现在可以吗?

2 个答案:

答案 0 :(得分:11)

看起来verb constraints就是你想要的。

match 'blah', to: 'users#blah', via: [:get, :post]

resources :users do
  collection do
    match 'blah', via: [:get, :post]
  end
end

答案 1 :(得分:3)

你可以输入相同的邮政路线名称,如下所示:

resources :users do
  collection do
    get 'blah'
    post 'blah'
  end
end

两条路线都有相同的控制器,动作和url_helpers

相关问题