Skip to content

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

@JuanfraM

Description

@JuanfraM

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions