igorkasyanchuk / rails_performance

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

Update base_controller.rb #2

Closed ghost closed 4 years ago

ghost commented 4 years ago

Make BaseController a subclass of ApplicationController rather than directly from ActionController::Base, so that app-specific code can be used in verifying access.

Maybe I'm missing something, but I couldn't see any other good way to get at current_user in the context of the rails performance controller. Clearance puts that on the application's own main controller, not on ActionController::Base.

scott-steadman commented 4 years ago

You could have them set a proc on your config object that you can call to get the current user.

igorkasyanchuk commented 4 years ago

@ffmike thank you, but this is not needed, you can see in the config this option, which you can use to check permissions

config.verify_access_proc = proc { |controller| controller.current_user && controller.current_user.admin? }

I want to keep gem as much as possible independent from main app

ghost commented 4 years ago

👍A reasonable approach. Note that the code in the config does not work in the case of apps using Clearance to provide current_user, but I'll work around.

igorkasyanchuk commented 4 years ago

you have access to the controller, so potentially you can do whatever you want.

I took that code from another my gem: https://github.com/igorkasyanchuk/any_login which by the way you can try! I can bet with you that it will be useful for you and it works with clearance.

igorkasyanchuk commented 4 years ago

@ffmike just noticed that you are the owner of http://afreshcup.com site! I'm really reading it for maybe 4-5 years like almost every day as a good source of news 👍 👍 💯

ghost commented 4 years ago

Thanks! And hope I didn't sound unfriendly above; I'm enjoying trying out this gem.

igorkasyanchuk commented 4 years ago

of course no, I really like that I see the first PR's for the gem :)

If you have some desire I actually have a good list of ideas - https://github.com/igorkasyanchuk/rails_performance#todo so whenever you have time you can pick any item from the list :)