flyerhzm / rails_best_practices

a code metric tool for rails projects
http://rails-bestpractices.com
MIT License
4.17k stars 276 forks source link

False positive: restrict auto-generated routes using resources with concern #345

Open JuanfraM opened 5 years ago

JuanfraM commented 5 years ago

Hi, I'm using rails 5.1.5 and rails_best_practices 1.16.0. I'm trying to use resources with a concern in the routes.rb but I'm having this error:

restrict auto-generated routes (only: [])

This is the code that generates the error with the concern in the resources groceries:

concern :shopper_actions do
   scope module: :shops do
        member do
          resources :orders, only: :index
       end
   end
end

namespace :shoppers do
  resources :groceries, param: :shop_id, controller: 'shops', only: :index,
                                       concerns: :shopper_actions
end

and this is the code that works fine without the concern:

namespace :shoppers do
  resources :groceries, param: :shop_id, controller: 'shops', only: :index do
     scope module: :shops do
         member do
            resources :orders, only: :index
          end
      end
   end
end