igorkasyanchuk / rails_performance

Monitor performance of you Rails applications (self-hosted and free)
https://www.railsjazz.com/
MIT License
976 stars 53 forks source link

Cannot skip setting `config.mount_at` when using `mount RailsPerformance::Engine` in routes.rb #59

Open LouisVallat opened 11 months ago

LouisVallat commented 11 months ago

How to reproduce :

  1. Install gem
  2. Follow README and put mount RailsPerformance::Engine in routes.rb to a specific route (let's say /dashboard/performance)
  3. Comment config.mount_at line in initializer
  4. Restart app
  5. Rails performance is both mounted at /rails/performance and /dashboard/performance

Looks like to culprit is https://github.com/igorkasyanchuk/rails_performance/blob/624f82915132a6a974033e49329478ff6dccd93b/lib/rails_performance.rb#L61 as it always sets a default that is then used by https://github.com/igorkasyanchuk/rails_performance/blob/624f82915132a6a974033e49329478ff6dccd93b/config/routes.rb#L21

A proposed fix could be to not set the default for @@mount_at or to interpret config.mount_at = false or config.mount_at = nil as a switch to disable auto mounting.

Of course it would also be needed to fix all calls to rails_performance_path.

I could do a pull request to implement either of these solutions if it suits your needs, or let me know if I missed anything 😄

Have a great day