How to disable “Cannot Render Console from…” on Rails

How to disable “Cannot Render Console from…” on Rails

Add Comment


  • 4 Answer(s)

    The 10.0.2.2 network space in the Web Console config. 

    class Application < Rails::Application
      config.web_console.whitelisted_ips = '10.0.2.2'
    end
    

    This  config/environments/development.rb rather than config/application.rb it  only applied development environment.

    Answered on January 12, 2019.
    Add Comment

    whitelist single IP’s or whole networks 192.168.0.100:

    class Application < Rails::Application
      config.web_console.whitelisted_ips = '192.168.0.100'
    end
    

    private network:

    class Application < Rails::Application
      config.web_console.whitelisted_ips = '192.168.0.0/16'
    end
    

    Option to false:

    class Application < Rails::Application
    config.web_console.whiny_requests = false
    end
    

    A development purposes might prefer to place it under config/environments/development.rb above of config/application.rb.

    Answered on January 12, 2019.
    Add Comment

    config/environments/development.rb:

    class Application < Rails::Application
      # Check if we use Docker to allow docker ip through web-console
      if ENV['DOCKERIZED'] == 'true'
        config.web_console.whitelisted_ips = ENV['DOCKER_HOST_IP']
      end
    end
    

    Docker-compose.yml  can inject env vars from this file with env_file:

    app:
      build: .
      ports:
        - "3000:3000"
      volumes:
        - .:/app
      links:
        - db
      environment:
       - DOCKERIZED=true
      env_file:
       - ".env"
    

    Answered on January 12, 2019.
    Add Comment

    Auto discovery within your config/development.rb

    config.web_console.whitelisted_ips = Socket.ip_address_list.reduce([]) do |res, addrinfo|
        addrinfo.ipv4? ? res << IPAddr.new(addrinfo.ip_address).mask(24) : res
    end

    Of course might need to add

    require 'socket'
    require 'ipaddr'

    Within your file.

    Answered on January 13, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.