Whois gem not working in rails

232 views Asked by At
class DomaincheckerController < ApplicationController
  def index
  end
  def store
    r =Whois.whois(secure_params['domain'])
    render :text => "#{r}"
  end

  private
  def secure_params
    params.require(:whois).permit(:domain)
  end


end

This is my domainchecker controller. The index method renders a form. After submitting the form it goes to store method. Here I am trying to use the whois gem. I have installed whois gem by running gem install whois. But I am getting this error.

uninitialized constant DomaincheckerController::Whois 
1

There are 1 answers

0
Simone Carletti On BEST ANSWER

The problem is that you installed the gem directly and not using bundler, therefore the Rails app can't find the dependency.

In order to install a gem in a Rails project you need to edit the Gemfile file and add the gem there. Once added, run

$ bundle

in order to install the dependency. Check the documentation about the Gemfile.