Ruby on Rails: configure web_console in initializer

333 views Asked by At

I am using the web_console gem and I would like to add some IPs to the whitelist. For reasons that would probably go to far to explain, can't simply add something to the config/application.rb or config/environments/development.rb. However I can create an initializer config/initializers/. I simple tried this in config/initializers/99-webconsole.rb, but while the file is loaded (--> debug message is shown), the web console does not seem to pick up my settings.

Rails.application.configure do
  config.web_console.whitelisted_ips = '10.10.0.0/16'
  p "Debug: this is loaded."
end

I assume it's related to some kind of race condition? Providing the same line in config/environments/development.rb works, but as said, I sadly can not change that file.

1

There are 1 answers

2
Saiqul Haq On

Based on this code https://github.com/rails/web-console/blob/e3dcf4c588af526eafcf1ce9413e62d846599538/lib/web_console/railtie.rb#L59

maybe there is a code in your initializer that configuring config.web_console.permissions, so your whitelisted_ips config is ignored

whitelisted_ips is also deprecated

and have you checked that you are using v4.2.0, the permissions was buggy and fixed by this commit https://github.com/rails/web-console/commit/6336c89385b58e88b2661ea3dc42fe28651d6296