Jerrod Jerrod - 1 year ago 188
Ruby Question

Ruby error: cannot load such file -- rest-client

I am using Ruby on Rails 4.

I am trying to

require 'rest-client'

in my controller so that I can parse the login information I am getting from a form and send it to an API.

I can verify that the gem is installed and is also in my Gemfile on the application root.

However, it is still throwing the "cannot load such file -- rest-client " when I try to require the file in my controller.

I have googled the error and most of the answers I saw were either the gem wasn't installed, wasn't in the Gemfile, or a combination of both those. Neither is the situation here.

Is my controller unable to access the rest-client gem for some reason? I have to use rest-client because it is required in the API.

This is the line I used to install the gem:

gem install rest-client

This is the homepage of the gem:

Which just redirects you to

I should also note that it works fine when I wasn't using the code in a Rails project but just running the commands in the Terminal.

Answer Source

Assuming you're using (since you didn't specify), your require line should be

require 'rest_client'

according to the README. Also, make sure you restart your rails server after adding the gem to your Gemfile and running bundle.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download