igorkasyanchuk / rails_db

Rails Database Viewer and SQL Query Runner
https://www.railsjazz.com/
MIT License
1.46k stars 111 forks source link

undefined method current_user #102

Closed chabgood closed 4 years ago

chabgood commented 4 years ago

Rails 5, getting:

undefined methodcurrent_user' for # when I doconfig.verify_access_proc = proc { |controller| controller.current_user.system_admin? }`

igorkasyanchuk commented 4 years ago

This is just an example. Do you use any authentication library like devise? You can add to own logic to block access to rails db.

chabgood commented 4 years ago

We do not use devise.

igorkasyanchuk commented 4 years ago

So just change logic in this block. Inside you have access to controller and could call your own verification methods

chabgood commented 4 years ago

since this is loaded up when rails starts how can i put in logic to see who the user is?

igorkasyanchuk commented 4 years ago
  1. comment this line if you don't need http://prntscr.com/pah2ye
  2. or change an appropriate logic, I don't know how you can check permissions, but you have access to controller and could implement all logic in this proc.
chabgood commented 4 years ago

I can do current_user from a controller, this is still giving me the same error. Is there a way to mix in current_user at a different time so it works?

igorkasyanchuk commented 4 years ago

What is your config/initializers/rails_db.rb? Paste it