Aug*_*ger 18 ruby-on-rails rails-routing ruby-on-rails-3 restful-architecture
我有一个NotificationsController
,我只有行动clear
.
我想通过POST/notifications/clear来访问此操作
所以我在路由器中写了这个:
resources :notifications, :only => [] do
collection do
post :clear
end
end
Run Code Online (Sandbox Code Playgroud)
有没有更清洁的方法来实现这一目标?我想
scope :notifications do
post :clear
end
Run Code Online (Sandbox Code Playgroud)
会这样做,但我有一个missing controller
错误,因为 - 我认为 - 它寻找clear
控制器.
rai*_*_id 20
如果您正在使用范围,则应添加一个控制器
scope :notifications, :controller => 'notifications' do
post 'clear'
end
Run Code Online (Sandbox Code Playgroud)
或者只使用命名空间
namespace :notifications do
post 'clear'
end
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10922 次 |
最近记录: |