require 'rubygems'
require 'mechanize'
agent = Mechanize.new
page = agent.get("http://google.com/")
This simple script works ok.
But if I'am trying to add
require 'rubygems'
and require 'mechanize'
to the Rails controller, server gives:
LoadError in NewsController#find
no such file to load -- mechanize
I use RVM on Ubuntu 10.04 server machnine. Ruby version: 1.9.2, Rails version: 3.0.3. Server: Passanger under Apache2.
P.S. If I run rails server
and go to mysite.com:3000 all works without any error, so there is a problem with Passanger!
Please, help me!
You shouldn't require gems in your controller. Thats why Bundler was added to Rails 3. Just add mechanize to your Gemfile like this
gem "mechanize"
and run
bundle install
on the command line. Any gem mentioned here will be required on application startup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With