Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gem available in irb but not rails console

I am trying to use the RedCloth gem in my rails project. When I used irb I can load the gem:

require 'rubygems'
require 'RedCloth'

and it works fine, but when I try the same thing in the rails console I get an error message stating that the gem cannot be found.

Does anyone have any idea what might cause this?

like image 406
robintw Avatar asked Jan 30 '11 19:01

robintw


2 Answers

You can append gem path to ruby load path. Do this:

gem which faker
=> /usr/local/ruby/......../faker-0.1.1/lib/faker.rb

Start Rails console and do the following:

$: << '/usr/local/ruby/......../faker-0.1.1/lib/'

and now load faker gem

require 'faker'
=> true
like image 125
Hitesh Sharma Avatar answered Oct 21 '22 16:10

Hitesh Sharma


Does your rails project's Gemfile include gem 'RedCloth' in it? Rails will only load the gems specified in that file.

like image 35
Dylan Markow Avatar answered Oct 21 '22 14:10

Dylan Markow