On Thu, 2006-06-01 at 16:09 +0100, Pedro C?rte-Real
wrote:> How do I use a model that has "acts_as_ferret" defined outside
rails?
> I''ve tried adding this to the top of my model:
>
> require
>
"#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb"
>
> and then defining RAILS_ROOT and RAILS_ENV in my app that uses the model
> outside rails. That got me this exception:
>
> ../vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb:465:in
> `ferret_create'': undefined method `debug'' for
nil:NilClass
> (NoMethodError)
>
> Anyone know what''s the correct way to do this?
I found a way to do it. At the start of my script:
require File.dirname(__FILE__) + ''/../config/boot''
ENV["RAILS_ENV"] = ''development''
require RAILS_ROOT + ''/config/environment''
After that I can use every model as if I was inside rails. I copied most
of this from the code for script/runner.
Cheers,
Pedro.