Ruby 如何将ActiveSupport::Concern应用于控制器中的特定操作?
我正在使用Grape构建一个API 我创建了一个名为Ruby 如何将ActiveSupport::Concern应用于控制器中的特定操作?,ruby,grape,activesupport-concern,Ruby,Grape,Activesupport Concern,我正在使用Grape构建一个API 我创建了一个名为Authentication的ActiveSupport::Concern并应用了一些before过滤器,因此我的关注点看起来像: module Authentication extend ActiveSupport::Concern included do before do error!('401 Unauthorized', 401) unless authenticated? end ...
Authentication
的ActiveSupport::Concern
并应用了一些before过滤器,因此我的关注点看起来像:
module Authentication
extend ActiveSupport::Concern
included do
before do
error!('401 Unauthorized', 401) unless authenticated?
end
....
end
end
现在,让我们假设在我的UserController中,我只想将此关注点应用于特定的操作。我该怎么做
class SocialMessagesController < Grape::API
include Authentication
get '/action_one' do
end
get '/action_two' do
end
end
class SocialMessageController
是否有任何简单的方法可以指定特定方法的关注点,就像rails中带有only
选项的before\u filter