1
我有轨道4担忧的一个问题在我的应用程序轨道4 - 关注资源问题
concern :common do
resources :comments
resources :categories
resources :tags
end
resources :articles, concerns: :common
resources :messages, concerns: :common
问题我面临的是,我想通过添加特定的控制器操作(例如,创建,编辑)的资源信息关注。我不知道如何通过关心的行动。请帮我通过资源定义
concern :common do |options|
resources :comments, options
resources :categories, options
resources :tags, options
end
resources :articles, concerns: :common
resources :messages do
concerns: :common, only: :create,:edit
end
我希望它会解决这个问题,解决这个问题
我该如何处理app/concern/common.rb中的类似逻辑 –
您可以使用self.call(映射器,选项)mapper.resources:comments,options .... – geekdev
您节省了我的时间,非常感谢, +1 –