Using acts_as_ferret outside Rails?


#1

I’m using the acts_as_ferret plugin successfully in a Rails application
but I also need to be able to use it (and ActiveRecord) outside of
Rails. Before I added the acts_as_ferret to the model I was able to use
ActiveRecord outside of Rails, but with acts_as_ferret it fails as
follows:

$ ruby runner.rb development

/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require': no such file to load -- acts_as_ferret (MissingSourceFile) from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
from
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1.5618/lib/active_support/dependencies.rb:489:in
require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1.5618/lib/active_support/dependencies.rb:337:innew_constants_in’
from
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1.5618/lib/active_support/dependencies.rb:489:in
require' from spider.rb:7 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:ingem_original_require’
from
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in
require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1.5618/lib/active_support/dependencies.rb:489:inrequire’
from
/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1.5618/lib/active_support/dependencies.rb:337:in
new_constants_in' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1.5618/lib/active_support/dependencies.rb:489:inrequire’
from components/runner.rb:8

I guess that this is something to do with me not including all of the
correct files but I’m having problems working out how. Is there a
‘proper’ way of using ActiveRecord outside of Rails (using 1.2 RC2)?
Currently I’m using the code sample from the Rails recipes book.

Cheers,

Ben


#2

Ben wrote:

I’m using the acts_as_ferret plugin successfully in a Rails application
but I also need to be able to use it (and ActiveRecord) outside of
Rails. Before I added the acts_as_ferret to the model I was able to use
ActiveRecord outside of Rails, but with acts_as_ferret it fails as
follows:

To reply to my own post, I fixed the problem by following the
guidelines below to create a rake task instead of hacking in the Rails
framework via includes.

http://www.fallenrogue.com/articles/168-Script-vs-Rake

Ben