Chamnap
Chamnap

Reputation: 4766

uninitialized constant ActiveRecord Model in rake script

I'm using rails 2.3.2 with ruby 1.8.7. I got some problems with my rake scripts. It seems it cannot load any activerecord model with production environment at all. It's so weird that is working with development environment. Here is my rake script:

task :indexing, :domain_name, :needs => :environment do |t, args|
   ActiveRecord::Base.establish_connection(RAILS_ENV)

   unless args.domain_name.blank?
      portals = [Portal.find_by_domain_name(args.domain_name)]
   else
      portals = Portal.actives
   end
end

Any suggestions?

Upvotes: 2

Views: 1698

Answers (1)

Heikki
Heikki

Reputation: 15417

Remove ActiveRecord::Base.establish_connection(RAILS_ENV).

This part loads your environment already: => :environment

Upvotes: 1

Related Questions