Rails 5 - Devise - Heroku NoMethodError - ruby-on-rails

I am trying to deploy a simple Rails 5 application in Heroku which has devise authentication enabled. I have followed a tutorial to deploy the Rails app on Heroku. The app is running and the database is also setup.
When I try to load the initial page of the app, where the user must be redirected to login page, I am getting following exception (in Heroku logs) -
Started GET "/" for 203.187.254.82 at 2018-05-04 10:28:24 +0000
Processing by HomeController#index as HTML
Completed 401 Unauthorized in 1ms
NoMethodError (undefined method `merge' for nil:NilClass):
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:805:in `url_for'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:277:in `call'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:218:in `call'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/route_set.rb:335:in `block (2 levels) in define_url_helper'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/routing/routes_proxy.rb:42:in `new_user_session_url'
vendor/bundle/ruby/2.3.0/gems/devise-4.4.3/lib/devise/failure_app.rb:153:in `scope_url'
vendor/bundle/ruby/2.3.0/gems/devise-4.4.3/lib/devise/failure_app.rb:128:in `redirect_url'
vendor/bundle/ruby/2.3.0/gems/devise-4.4.3/lib/devise/failure_app.rb:88:in `redirect'
vendor/bundle/ruby/2.3.0/gems/devise-4.4.3/lib/devise/failure_app.rb:43:in `respond'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/abstract_controller/base.rb:186:in `process_action'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/abstract_controller/base.rb:124:in `process'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_controller/metal.rb:189:in `dispatch'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_controller/metal.rb:242:in `block in action'
vendor/bundle/ruby/2.3.0/gems/devise-4.4.3/lib/devise/failure_app.rb:23:in `call'
vendor/bundle/ruby/2.3.0/gems/devise-4.4.3/lib/devise/delegator.rb:7:in `call'
vendor/bundle/ruby/2.3.0/gems/warden-1.2.7/lib/warden/manager.rb:143:in `call_failure_app'
vendor/bundle/ruby/2.3.0/gems/warden-1.2.7/lib/warden/manager.rb:129:in `process_unauthenticated'
vendor/bundle/ruby/2.3.0/gems/warden-1.2.7/lib/warden/manager.rb:44:in `call'
vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/etag.rb:25:in `call'
vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/conditional_get.rb:25:in `call'
vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/head.rb:12:in `call'
vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:232:in `context'
vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/session/abstract/id.rb:226:in `call'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/cookies.rb:613:in `call'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/callbacks.rb:97:in `run_callbacks'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/callbacks.rb:24:in `call'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
vendor/bundle/ruby/2.3.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:36:in `call_app'
vendor/bundle/ruby/2.3.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:24:in `block in call'
vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/tagged_logging.rb:69:in `block in tagged'
vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/tagged_logging.rb:26:in `tagged'
vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/tagged_logging.rb:69:in `tagged'
vendor/bundle/ruby/2.3.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:24:in `call'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/request_id.rb:25:in `call'
vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/method_override.rb:22:in `call'
vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/runtime.rb:22:in `call'
vendor/bundle/ruby/2.3.0/gems/activesupport-5.1.6/lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/executor.rb:12:in `call'
vendor/bundle/ruby/2.3.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/static.rb:125:in `call'
vendor/bundle/ruby/2.3.0/gems/rack-2.0.5/lib/rack/sendfile.rb:111:in `call'
vendor/bundle/ruby/2.3.0/gems/railties-5.1.6/lib/rails/engine.rb:522:in `call'
vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/configuration.rb:225:in `call'
vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/server.rb:632:in `handle_request'
vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/server.rb:446:in `process_client'
vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/server.rb:306:in `block in run'
vendor/bundle/ruby/2.3.0/gems/puma-3.11.4/lib/puma/thread_pool.rb:120:in `block in spawn_thread'
home_controller.rb
class HomeController < ApplicationController
before_action :authenticate_user!
def index
#activities = nil
end
def posts
#posts = Post.all.order("created_at DESC")
end
end
What am I missing here? Not able to understand whether the exception is from the devise library or my application code.

I have resolved it. I found it from actionpack's code that url_for method requires default_url_options config to be set in respective environment file.
In my case it was in production.rb file.
I had to put-in -
config.action_mailer.default_url_options = { :host => '<YOUR_HEROKU_APP_URL_HERE>' }

Related

Web site error generates a Ruby on Rails error instead of the classical red error page in Rails 6.1

I recently started with Rails 6.1 on Windows server. It runs as expected and shows Rails welcome screen. Including the Rails red page if I generate an error in the code.
Then I installed webpack, Yarn etc. and started copying some models from an old application I'd like to reuse. Since then any error in the code breaks Rails: instead of the expected red page, it drops hundreds of lines with the following errors repeated several times:
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/actionview-6.1.4/lib/action_view/template.rb:300: warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/web-console-3.7.0/lib/web_console/exception_mapper.rb:31: warning: in `eval'
And then another bloc:
ArgumentError: wrong number of arguments (given 2, expected 3)
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/actionview-6.1.4/lib/action_view/base.rb:230:in `initialize'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/web-console-3.7.0/lib/web_console/template.rb:21:in `new'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/web-console-3.7.0/lib/web_console/template.rb:21:in `render'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/web-console-3.7.0/lib/web_console/middleware.rb:37:in `block in call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/web-console-3.7.0/lib/web_console/middleware.rb:20:in `catch'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/web-console-3.7.0/lib/web_console/middleware.rb:20:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/rack/logger.rb:37:in `call_app'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/rack/logger.rb:26:in `block in call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4/lib/active_support/tagged_logging.rb:99:in `block in tagged'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4/lib/active_support/tagged_logging.rb:37:in `tagged'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4/lib/active_support/tagged_logging.rb:99:in `tagged'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/rack/logger.rb:26:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4/lib/action_dispatch/middleware/request_id.rb:26:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/activesupport-6.1.4/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4/lib/action_dispatch/middleware/executor.rb:14:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4/lib/action_dispatch/middleware/static.rb:24:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/actionpack-6.1.4/lib/action_dispatch/middleware/host_authorization.rb:98:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/webpacker-4.3.0/lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rack-proxy-0.7.0/lib/rack/proxy.rb:63:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/railties-6.1.4/lib/rails/engine.rb:539:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/puma-5.4.0/lib/puma/configuration.rb:249:in `call'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/puma-5.4.0/lib/puma/request.rb:77:in `block in handle_request'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/puma-5.4.0/lib/puma/thread_pool.rb:340:in `with_force_shutdown'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/puma-5.4.0/lib/puma/request.rb:76:in `handle_request'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/puma-5.4.0/lib/puma/server.rb:440:in `process_client'
from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/puma-5.4.0/lib/puma/thread_pool.rb:147:in `block in spawn_thread'
What did I break ?

Rails 4 - Assets routing error

I am transitioning from Heroku to AWS Elastic Beanstalk and in my logs I keep seeing this error with .css and .js assets.
Rails 4.2
Ruby 2.2.5
ActionController::RoutingError (No route matches [GET] "/assets/application-be8de4c1a8d12cb784028972b73fe7e23d4acc55757e3d297ef5e3db4161c369.css"):
vendor/bundle/gems/actionpack-4.2.2/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
vendor/bundle/gems/actionpack-4.2.2/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
vendor/bundle/gems/railties-4.2.2/lib/rails/rack/logger.rb:38:in `call_app'
vendor/bundle/gems/railties-4.2.2/lib/rails/rack/logger.rb:20:in `block in call'
vendor/bundle/gems/activesupport-4.2.2/lib/active_support/tagged_logging.rb:68:in `block in tagged'
vendor/bundle/gems/activesupport-4.2.2/lib/active_support/tagged_logging.rb:26:in `tagged'
vendor/bundle/gems/activesupport-4.2.2/lib/active_support/tagged_logging.rb:68:in `tagged'
vendor/bundle/gems/railties-4.2.2/lib/rails/rack/logger.rb:20:in `call'
vendor/bundle/gems/actionpack-4.2.2/lib/action_dispatch/middleware/request_id.rb:21:in `call'
vendor/bundle/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
vendor/bundle/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
vendor/bundle/gems/activesupport-4.2.2/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
vendor/bundle/gems/actionpack-4.2.2/lib/action_dispatch/middleware/static.rb:113:in `call'
vendor/bundle/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
vendor/bundle/gems/actionpack-4.2.2/lib/action_dispatch/middleware/ssl.rb:24:in `call'
vendor/bundle/gems/railties-4.2.2/lib/rails/engine.rb:518:in `call'
vendor/bundle/gems/railties-4.2.2/lib/rails/application.rb:164:in `call'
vendor/bundle/gems/puma-3.6.2/lib/puma/configuration.rb:225:in `call'
vendor/bundle/gems/puma-3.6.2/lib/puma/server.rb:578:in `handle_request'
vendor/bundle/gems/puma-3.6.2/lib/puma/server.rb:415:in `process_client'
vendor/bundle/gems/puma-3.6.2/lib/puma/server.rb:275:in `block in run'
vendor/bundle/gems/puma-3.6.2/lib/puma/thread_pool.rb:116:in `call'
vendor/bundle/gems/puma-3.6.2/lib/puma/thread_pool.rb:116:in `block in spawn_thread'
Help.
Could it be that your configuration file is telling EB to skip asset compilation? See docs here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Ruby.container.html#create_deploy_Ruby.env.console.ruby.envprops

how to reopen a class in gems

I have same class in main application and a gem (mountable engine).
I want to reopen the class(defined in main applicaion) in the gem.
Main application has
app/models/test.rb
class Test
def original_method
end
end
in Gemfile
gem 'gem_name'
In the gem
app/models/test.rb
class Test
def add_method
end
end
But main application raises an error that Test#original_method is not defined.
It looks like Test class is overwritten in the gem. Why not reopen?
How can I solve the problem??
EDIT
NoMethodError (undefined method `original_method' for #<Test:0x0000001997ca70>):
vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.13/lib/active_model/attribute_methods.rb:407:in `method_missing'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/attribute_methods.rb:149:in `method_missing'
vendor/bundle/ruby/1.9.1/bundler/gems/test_gem/app/controllers/tests_controller.rb:213:in `new'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:167:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/rendering.rb:10:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:535:in `_run__422315203817736318__process_action__439125674649202736__callbacks'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/callbacks.rb:17:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/rescue.rb:29:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/base.rb:121:in `process'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in `process'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal.rb:203:in `dispatch'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_controller/metal.rb:246:in `block in action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:in `call'
vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call'
vendor/bundle/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
vendor/bundle/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch'
vendor/bundle/ruby/1.9.1/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in `call'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/query_cache.rb:64:in `call'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `_run__4226710667851682500__call__4227166089575601802__callbacks'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:65:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/rack/logger.rb:32:in `call_app'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `block in call'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in `tagged'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/rack/logger.rb:16:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in `call'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:479:in `call'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:223:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/rack/log_tailer.rb:17:in `call'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service'
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/usr/local/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
try
Test.class_eval do
def original_method
end
end
This is an old question, but I just came across it looking for an answer and found my own. Here's how I did it in a Rails app. Basically, instead of reopening the class you put the code in a module and include it in the original class.
# lib/extensions/gem_name/name_of_feature.rb
module Extensions
module GemName
module NameOfFeature
def self.included(base)
base.extend ClassMethods
base.class_eval do
# Things like association macros here
# I.ex. belongs_to :foo
end
end
def some_instance_method
# Do something
end
module ClassMethods
def some_class_method
# Do something
end
end
end
end
end
# config/initializers/gem_name.rb
require "extensions/gem_name/name_of_feature"
GemClassToExtend.include Extensions::GemName::NameOfFeature
So now you can:
GemClassToExtend.some_class_method
GemClassToExtend.new.some_instance_method
You have two test.rb files and only one of them is being loaded in your current environment. I recommend creating a mixin module in your application and then including it into the Test class defined in the gem.
module TestExtensions
def original_method
end
end
Test.include(TestExtensions)
Aside: I typically discourage monkey patching gem dependencies in this manner. Consider making a wrapper around Test.
The exception you have attached claims about undefined method original_method? not original_method. Looks like you are trying to call a method with ? at the end while it is not defined.

Rails ArgumentError: invalid %-encoding

For the last month, we've had a bot scraping our site regularly, leading to a bunch of ArgumentError: invalid %-encoding errors because the URLs are malformed. I've looked at a bunch of issues in rack here and here and rails here, and looked at this SO thread but there doesn't seem to be a definitive solution. Is there a correct solution for GET errors? Do I have to monkeypatch rack?
edit: And here's a backtrace:
/usr/local/lib/ruby/1.9.1/uri/common.rb:898:in `decode_www_form_component'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/utils.rb:41:in `unescape'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/utils.rb:94:in `block (2 levels) in parse_nested_query'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/utils.rb:94:in `map'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/utils.rb:94:in `block in parse_nested_query'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/utils.rb:93:in `each'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/utils.rb:93:in `parse_nested_query'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/request.rb:332:in `parse_query'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/http/request.rb:269:in `parse_query'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/request.rb:186:in `GET'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/http/request.rb:225:in `GET'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/http/parameters.rb:10:in `parameters'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/http/filter_parameters.rb:33:in `filtered_parameters'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:21:in `process_action'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
[GEM_ROOT]/gems/activerecord-3.2.12/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/abstract_controller/base.rb:121:in `process'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/abstract_controller/rendering.rb:45:in `process'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_controller/metal.rb:203:in `dispatch'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_controller/metal.rb:246:in `block in action'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:73:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:36:in `call'
[GEM_ROOT]/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
[GEM_ROOT]/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
[GEM_ROOT]/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:601:in `call'
[GEM_ROOT]/gems/omniauth-1.1.1/lib/omniauth/strategy.rb:177:in `call!'
[GEM_ROOT]/gems/omniauth-1.1.1/lib/omniauth/strategy.rb:157:in `call'
[GEM_ROOT]/gems/sass-3.2.7/lib/sass/plugin/rack.rb:54:in `call'
[GEM_ROOT]/gems/warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
[GEM_ROOT]/gems/warden-1.2.1/lib/warden/manager.rb:34:in `catch'
[GEM_ROOT]/gems/warden-1.2.1/lib/warden/manager.rb:34:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/head.rb:14:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/flash.rb:242:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/cookies.rb:341:in `call'
[GEM_ROOT]/gems/activerecord-3.2.12/lib/active_record/query_cache.rb:64:in `call'
[GEM_ROOT]/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
[GEM_ROOT]/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `_run__497203393471184793__call__4495106819278994598__callbacks'
[GEM_ROOT]/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
[GEM_ROOT]/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
[GEM_ROOT]/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
[GEM_ROOT]/gems/railties-3.2.12/lib/rails/rack/logger.rb:32:in `call_app'
[GEM_ROOT]/gems/railties-3.2.12/lib/rails/rack/logger.rb:16:in `block in call'
[GEM_ROOT]/gems/activesupport-3.2.12/lib/active_support/tagged_logging.rb:22:in `tagged'
[GEM_ROOT]/gems/railties-3.2.12/lib/rails/rack/logger.rb:16:in `call'
[GEM_ROOT]/gems/actionpack-3.2.12/lib/action_dispatch/middleware/request_id.rb:22:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
[GEM_ROOT]/gems/activesupport-3.2.12/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:172:in `rescue in lookup'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:168:in `lookup'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
[GEM_ROOT]/gems/railties-3.2.12/lib/rails/engine.rb:479:in `call'
[GEM_ROOT]/gems/railties-3.2.12/lib/rails/application.rb:223:in `call'
[GEM_ROOT]/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/abstract_request_handler.rb:516:in `accept_and_process_next_request'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/rack/application_spawner.rb:171:in `block in handle_spawn_application'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/utils.rb:479:in `safe_fork'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server.rb:180:in `start'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/spawn_manager.rb:246:in `block in spawn_rack_application'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/spawn_manager.rb:244:in `spawn_rack_application'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/spawn_manager.rb:137:in `spawn_application'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.13/helper-scripts/passenger-spawn-server:99:in `<main>'
if you don't mind against monkeypatching Rack then create in config/initializers file (for example rack.rb) with this content:
module Rack
module Utils
if defined?(::Encoding)
def unescape(s, encoding = Encoding::UTF_8)
begin
URI.decode_www_form_component(s, encoding)
rescue ArgumentError
URI.decode_www_form_component(URI.encode(s), encoding)
end
end
else
def unescape(s, encoding = nil)
begin
URI.decode_www_form_component(s, encoding)
rescue ArgumentError
URI.decode_www_form_component(URI.encode(s), encoding)
end
end
end
module_function :unescape
end
end
p.s. it works with passenger, but with Webrick and Thin it doesn't. It looks like both webrick and thin parse a request too, so the failure happens before initializer is loaded. For example with Thin error happens in thin-1.6.2/lib/thin/request.rb:84.
You could inject a middleware designed to detect these and fail gracefully. The basic idea is to just try to parse the query string, and if it fails, bail out with a HTTP 400. Otherwise, just allow the request through.
class RefuseInvalidRequest
def initialize(app)
#app = app
end
def call(env)
query = Rack::Utils.parse_nested_query(env['QUERY_STRING'].to_s) rescue :bad_query
if query == :bad_query
[400, {'Content-Type' => 'text/plain'}, "Bad Request"]
else
#app.call(env)
end
end
end
I haven't tested this, but the concept should work.

Rails app starts but Errors

My Rails app starts but gives me a No Method error. I'm not sure what method is apparently being called on something which doesn't. It can;t be a certain site page as it's happening on every url I try to visit. Anyone able hint where it's failing?
Full stack log:
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/error_frame.rb:7:in `block in from_exception'
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/error_frame.rb:4:in `each'
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/error_frame.rb:4:in `each_with_index'
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/error_frame.rb:4:in `each'
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/error_frame.rb:4:in `map'
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/error_frame.rb:4:in `from_exception'
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/error_page.rb:45:in `backtrace_frames'
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/middleware.rb:31:in `log_exception'
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/middleware.rb:23:in `rescue in app_call'
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/middleware.rb:20:in `app_call'
vendor/ruby/1.9.1/gems/better_errors-0.0.8/lib/better_errors/middleware.rb:14:in `call'
vendor/ruby/1.9.1/gems/bullet-4.1.5/lib/bullet/rack.rb:11:in `call'
vendor/ruby/1.9.1/gems/sass-3.2.0/lib/sass/plugin/rack.rb:54:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/head.rb:14:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/flash.rb:242:in `call'
vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/cookies.rb:339:in `call'
vendor/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/query_cache.rb:64:in `call'
vendor/ruby/1.9.1/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
vendor/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `_run__2841213657923326046__call__4410644436419050805__callbacks'
vendor/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
vendor/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
vendor/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/reloader.rb:65:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
vendor/ruby/1.9.1/gems/railties-3.2.8/lib/rails/rack/logger.rb:26:in `call_app'
vendor/ruby/1.9.1/gems/railties-3.2.8/lib/rails/rack/logger.rb:16:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/request_id.rb:22:in `call'
vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
vendor/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
vendor/ruby/1.9.1/gems/actionpack-3.2.8/lib/action_dispatch/middleware/static.rb:62:in `call'
vendor/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:479:in `call'
vendor/ruby/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:223:in `call'
vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
vendor/ruby/1.9.1/gems/railties-3.2.8/lib/rails/rack/log_tailer.rb:17:in `call'
vendor/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
/Users/<user>/.rbenv/versions/1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/<user>/.rbenv/versions/1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/<user>/.rbenv/versions/1.9.3-p362/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Error given:
NoMethodError in PagesController#home
undefined method `[]' for nil:NilClass
I'm sure you quite beyond this but just to chime in, I had the same error. I commented out the better_errors gem, re-bundled, reran my app, and found I was getting an error elsewhere. I don't know why better_errors was unable to handle it but once I fixed that other error, I re-enabled better_errors and everything was back to normal.
It's odd b/c I haven't had any problems with the gem before. I love it.

Resources