Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Addressable gem is not found

In my Gemfile I have:

gem 'addressable'

In search_controller.rb:

uri = Addressable::URI.new
uri.query_values = {:q => query}

I get this error:

NameError (uninitialized constant SearchController::Addressable):

If I put

require 'addressable/uri'

on top of my controller, it works!!. I have already done "sudo bundle install" and it shows addressable is installed. What am I doing wrong?

like image 274
shane Avatar asked Feb 20 '23 02:02

shane


1 Answers

Looking at addressable gem source I see it has no lib/addressable.rb which is default file which rubygems or bundler require when loading required gem. So it looks like it is designed this way on purpose - to make you explicitly require only the libraries you need.

like image 168
khustochka Avatar answered Feb 27 '23 23:02

khustochka