2

I am trying to run the rails web-console from https://github.com/rails/web-console in production. I know there are warnings against doing this, but the app where I intend to use it is internal and not accessible in production.

Configurations I've used:

config.web_console.development_only = false config.web_console.whitelisted_ips = %w(<IPs that should have permission>)

So the console ends up working perfectly in development and test, but fails with a very weird error in production.

ArgumentError: wrong number of arguments (given 0, expected 1)
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.3/lib/active_support/core_ext/kernel/reporting.rb:89:in `capture`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/web-console-3.3.0/lib/web_console/view.rb:34:in `render`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/web-console-3.3.0/lib/web_console/template.rb:20:in `render`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/web-console-3.3.0/lib/web_console/middleware.rb:36:in `block in call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/web-console-3.3.0/lib/web_console/middleware.rb:18:in `catch`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/web-console-3.3.0/lib/web_console/middleware.rb:18:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.3/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/railties-4.2.3/lib/rails/rack/logger.rb:38:in `call_app`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/railties-4.2.3/lib/rails/rack/logger.rb:20:in `block in call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in `block in tagged`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:26:in `tagged`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in `tagged`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/railties-4.2.3/lib/rails/rack/logger.rb:20:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.3/lib/action_dispatch/middleware/request_id.rb:21:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.3/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.3/lib/action_dispatch/middleware/static.rb:116:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/railties-4.2.3/lib/rails/engine.rb:518:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/railties-4.2.3/lib/rails/application.rb:165:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/lock.rb:17:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/content_length.rb:15:in `call`
    from /Users/someuser/.rvm/gems/ruby-2.3.1/gems/rack-1.6.4/lib/rack/handler/webrick.rb:88:in `service`
    from /Users/someuser/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service`
    from /Users/someuser/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run`
    from /Users/someuser/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread`

Can I modify the gem somehow to make it work? Or is there a workaround?

Ruby: v2.3.1 Rails: v4.2.1 web-console: v3.3.0

Thank you

UPDATE:

I found a solution to the problem. It has something to do with how the gem handles logging. I am still not sure why it works in development and not in production though. Here is what I did to get it to work

I added the following code to config/initializers/web_console.rb

WebConsole::View.class_eval do
  def render(*)
    super
  end
end

Essentially, I've overridden the render(*) method located at https://github.com/rails/web-console/commit/4ba9f5044f9322ea16f97e69b7167170c9c34522

Thanks for the help everyone

2 Answers 2

2

You encountered the same issue here: https://github.com/rails/web-console/issues/204. Upgrade web-console to 3.4.0 may help to resolve the problem.

Sign up to request clarification or add additional context in comments.

1 Comment

I am not actually using Rails 5 so that may be an issue. I see a few other options in the comments there that I may try out. I'll update the OP when I have progress. In the mean time, v 2.0.0 works good enough
1

UPDATE:

I found a solution to the problem. It has something to do with how the gem handles logging. I am still not sure why it works in development and not in production though. Here is what I did to get it to work

I added the following code to config/initializers/web_console.rb

WebConsole::View.class_eval do
  def render(*)
    super
  end
end

Essentially, I've overridden the render(*) method located at https://github.com/rails/web-console/commit/4ba9f5044f9322ea16f97e69b7167170c9c34522

Thanks for the help everyone

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.