Reputation: 183599
I was trying to use the Addressable gem in a specific action in Rails.
My usual practice is to include the gem in the Gemfile, and then require the module where needed.
Gemfile:
gem 'addressable'
some_controller.rb:
class SomeController < ApplicationController
def new
require "addressable/uri"
current_url = Addressable::URI.parse(request.original_url)
....
end
end
However, I was getting a 500 error on other actions/controllers that did not use the gem.
Error during failsafe response: uninitialized constant Addressable
Finally, I removed all the code calling addressable, but kept the entry in the gemfile, and the 500 error persists on all actions. Why would this be?
Upvotes: 3
Views: 1135
Reputation: 27961
Not sure why you're getting that specific error, but with a gem like Addressable where you don't want an automatic require 'addressable'
performed then in your Gemfile
you should have:
gem 'addressable', :require => false
Upvotes: 2