[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby without Rails

rasfast

8/14/2008 3:23:00 PM

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:in `require'
[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:in
`handler'

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.
1 Answer

Hongli Lai

8/14/2008 3:51:00 PM

0

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.ruby...
[2] http://www.mod...


> 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.
--
Posted via http://www.ruby-....