2013-09-30 28 views
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 

我希望它會解決這個問題,解決這個問題

回答

0

可選參數可以傳遞到擔憂。

+0

我該如何處理app/concern/common.rb中的類似邏輯 –

+0

您可以使用self.call(映射器,選項)mapper.resources:comments,options .... – geekdev

+0

您節省了我的時間,非常感謝, +1 –