Question

I'm trying to build an app using Sinatra, Ruby, rack, haml, pony and SendGrid, with git and RVM for deployment on Heroku. The app is a blog variant that should send out an email with commentary submitted on a form. On my local server, when the form submits I get the following error:

LoadError at /
cannot load such file -- pony
file: tools.rb location: require line: 314
BACKTRACE
(expand)
/Users/Kevin/prog/ruby/Sinatra/Noobs/noobs.rb in block in <top (required)>
  require 'pony'

When run on Heroku, form submittal results in an internal server error. The 'cannot load such file' error suggests that the file is not on the gem path, but if I understand correctly, the OS disagrees:

➜  noobs git:(master) ✗ bundle show pony
/Users/Kevin/.rvm/gems/ruby-1.9.3-p194@noobs/gems/pony-1.4

➜  noobs git:(master) echo $GEM_PATH
/Users/Kevin/.rvm/gems/ruby-1.9.3-p194@noobs:/Users/Kevin/.rvm/gems/ruby-1.9.3-p194@global

Here is the code where pony is required (noobs.rb):

require 'rubygems'
require 'sinatra'
require 'haml'
require "sinatra/reloader" if development?  

# ...

post '/' do
  require 'pony'
  Pony.mail(:from => params[:name] + "<" + params[:contact] + ">",

What do I need to do to get pony to work?

Was it helpful?

Solution

require "bundler/setup"

Will probably fix your error.

Since you are using Bundler with Sinatra you need to require Bundler for the bundled gems to work. You probably have your gems split between Bundler and your gemset. If you have Sinatra and Haml in your gemset but Pony in your Gemfile you will see a LoadError.

OTHER TIPS

I write down name of the gem (pony - in my case) in Gemfile - and it starts to work. Just open Jemfile - and write down words jem "pony" in the new line I get the following paste2.org/6hVxHXKH

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top