Hi all,
I'm trying to write a simple custom rake task to easily delete some database records. However when I run it, I get an error 'development database is not configured'.

Here's the code:
lib/tasks/custom.rake

require 'activerecord'

namespace :db do
 task :delete_sessions do
   sessions = ENV['sessions'].split(',').collect! {|n| n.to_i}
   ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
   for session in sessions do
ActiveRecord::Base.connection.execute("DELETE FROM pool_sessions WHERE pool_session_id=#{session};") end end
end

And how I call it:

$ rake db:delete_sessions sessions=1,2
(in <rails root>)
rake aborted!
development database is not configured

(See full trace by running task with --trace)

If I change RAILS_ENV to test or production I get parallel results.

I can still do other rake db tasks, such as drop, create, and migrate, so I know that my config/database.yml is OK.

Any ideas?  Thanks.
-David

--
David van Geest
Software Engineer
Spindance, Inc.
616.355.7000 x113

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to