amatsuda / traceroute

A Rake task gem that helps you find the unused routes and controller actions for your Rails 3+ app
MIT License
902 stars 38 forks source link

False positive among unreachable action methods when using draper to decorate #42

Open lioneldebauge opened 3 years ago

lioneldebauge commented 3 years ago

I have this controller (simplified for the sake of clarity)

module BackOffice
  class MaintenancePeriodsController < BackOfficeController
    decorates_assigned :housing_unit

    def create
    end

    def destroy
    end

    def edit
    end

    def update
    end
  end
end

with these routes

# routes.rb
    resources :housing_units do
      resources :maintenance_periods, only: %i[create destroy edit update]
    end

               back_office_housing_unit_maintenance_periods POST   /back_office/housing_units/:housing_unit_id/maintenance_periods(.:format)                         back_office/maintenance_periods#create
           edit_back_office_housing_unit_maintenance_period GET    /back_office/housing_units/:housing_unit_id/maintenance_periods/:id/edit(.:format)                back_office/maintenance_periods#edit
                back_office_housing_unit_maintenance_period PATCH  /back_office/housing_units/:housing_unit_id/maintenance_periods/:id(.:format)                     back_office/maintenance_periods#update
                                                            PUT    /back_office/housing_units/:housing_unit_id/maintenance_periods/:id(.:format)                     back_office/maintenance_periods#update
                                                            DELETE /back_office/housing_units/:housing_unit_id/maintenance_periods/:id(.:format)                     back_office/maintenance_periods#destroy

When I run rake routes I get this even though I clearly don't have any controller action called housing_unit

Unreachable action methods (214):
  back_office/maintenance_periods#housing_unit

My guess is that Draper adds a method under the hood to decorate an object in our codebase called HousingUnit. They showed a basic example of that in their README.md

Could you confirm that and if so tell us how we can go around this issue ?

Thanks in advance for all your help and this very cool gem 🙏