Ruby without Rails

Hello!

I have a Rails application, and now I’m trying to make a cgi-script
out of Rails, but it should operate with Rails database and models.

Problem 1.
Next script doesn’t seem to work everywhere:
require ‘rubygems’
gem ‘activerecord’, ‘=2.1.0’
require ‘active_record’
require ‘yaml’

ActiveRecord::Base.establish_connection( YAML.load_file(“config/
database.yml”)[‘development’] )

It works perfectly from console, but I cannot force it to work as a
web page. It gives me “500 Internal error” page, and Apache log says
me:
[error] mod_ruby: error in ruby
[error] mod_ruby: /usr/local/lib/site_ruby/1.8/rubygems/
custom_require.rb:32:in gem_original_require': no such file to load -- active_record (LoadError) [error] mod_ruby: from /usr/local/lib/site_ruby/1.8/rubygems/ custom_require.rb:32:inrequire’
[error] mod_ruby: from /var/www/pc/api.rbx:6
[error] mod_ruby: from /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in
load' [error] mod_ruby: from /usr/lib/ruby/1.8/apache/ruby-run.rb:53:inhandler’

My configuration:
Ubuntu 7.10
Apache 2.2.4 + mod_ruby + mod_fcgid
Ruby 1.8.6
Rails 2.1.0

Problem 2.
One of my models “acts as tree” in the Rails application. But how can
I make it to work in my cgi-script?
I have tried:
require ‘vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb’
But it doesn’t help.

Thanks in advance,
Konstantin.

unknown wrote:

Hello!

I have a Rails application, and now I’m trying to make a cgi-script
out of Rails, but it should operate with Rails database and models.
[…]
My configuration:
Ubuntu 7.10
Apache 2.2.4 + mod_ruby + mod_fcgid
Ruby 1.8.6
Rails 2.1.0

mod_ruby hasn’t been maintained since 2006, and people generally avoid
it. FastCGI is in a similar situations: people tend to avoid it because
its implementation has all kinds of problems.

Maybe you should consider using Rack [1] in combination with Phusion
Passenger [2] instead?

[1] http://rack.rubyforge.org/
[2] http://www.modrails.com/

Problem 2.
One of my models “acts as tree” in the Rails application. But how can
I make it to work in my cgi-script?
I have tried:
require ‘vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb’
But it doesn’t help.

Do ‘require “config/environment”’. This will load the Rails environment
and initialize plugins, but you will retain full control over how the
application processes HTTP requests.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs