I have the following skeleton for a rake task: =========namespace :db do desc "Populate database for first time based on export from AS/400 system" task :populate_from_export do ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[''development'']) User.find(:all) puts "hello world" end end ========= I want to be able to call User.find(:all) from my rake task but I am getting the following error: development database is not configured If I get rid of the first line of the task I get the following error: ActiveRecord::ConnectionNotEstablished So how do I make a proper conneection and make my models accessible to me for a rake task? Thanks for your help :-). Your Friend, John -- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org http://www.kopanas.com http://www.cusec.net http://www.soen.info --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 11/21/06, John Kopanas <kopanas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have the following skeleton for a rake task: > > =========> namespace :db do > > desc "Populate database for first time based on export from AS/400 system" > task :populate_from_export doYou need to make sure your config files are loaded. Try: task :populate_from_export => [ :environment ] do instead of the line above my comment. Isak> ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[''development'']) > User.find(:all) > puts "hello world" > end > > end > =========> > I want to be able to call User.find(:all) from my rake task but I am > getting the following error: > > development database is not configured > > If I get rid of the first line of the task I get the following error: > > ActiveRecord::ConnectionNotEstablished > > So how do I make a proper conneection and make my models accessible to > me for a rake task? > > Thanks for your help :-). > > Your Friend, > > John > > -- > John Kopanas > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > http://www.kopanas.com > http://www.cusec.net > http://www.soen.info > > > >--~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Perfect.... thanks :-). On 11/21/06, Isak Hansen <isak.hansen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 11/21/06, John Kopanas <kopanas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have the following skeleton for a rake task: > > > > =========> > namespace :db do > > > > desc "Populate database for first time based on export from AS/400 system" > > task :populate_from_export do > > You need to make sure your config files are loaded. Try: > > task :populate_from_export => [ :environment ] do > > instead of the line above my comment. > > > Isak > > > > ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[''development'']) > > User.find(:all) > > puts "hello world" > > end > > > > end > > =========> > > > I want to be able to call User.find(:all) from my rake task but I am > > getting the following error: > > > > development database is not configured > > > > If I get rid of the first line of the task I get the following error: > > > > ActiveRecord::ConnectionNotEstablished > > > > So how do I make a proper conneection and make my models accessible to > > me for a rake task? > > > > Thanks for your help :-). > > > > Your Friend, > > > > John > > > > -- > > John Kopanas > > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > > > http://www.kopanas.com > > http://www.cusec.net > > http://www.soen.info > > > > > > > > > > >-- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org http://www.kopanas.com http://www.cusec.net http://www.soen.info --~--~---------~--~----~------------~-------~--~----~ 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---