2
votes

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?

1
What is the error you get from that? - Heikki
uninitialized constant Portal - Chamnap
Does it work if you remove temporarily , :domain_name, :needs part? - Heikki
It works, so what should I do? How to add parameter and load rails env at the same time? - Chamnap
I tried quickly with Rails 2.3.2 and it seems to work? What is your rake version? - Heikki

1 Answers

1
votes

Remove ActiveRecord::Base.establish_connection(RAILS_ENV).

This part loads your environment already: => :environment