The application I am working on needs a nightly process to comb through the database and make periodic changes. What is the best way to implement a script in order to leverage the existing database connection management and active record functionality? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Dan Munk wrote:> The application I am working on needs a nightly process to comb through > the database and make periodic changes. > > What is the best way to implement a script in order to leverage the > existing database connection management and active record > functionality?Tell the OS to periodically run a script using ''cron'', or the Task Manager, or some derivative therof. Some are called ''at''. The script may run something like this: ruby script/runner "load(''my_batch.rb'')" my_batch.rb then contains a batch of Ruby, enjoying the complete Rails context. IIRC. There might be other ways to invoke the runner script. --help didn''t confess them. -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Phlip, I have no problem with the scheduling of the script. I really want to understand how people are writing the scripts themselves share the existing database connections and use active record. For instance: 1. Periodic web service invocation. 2. External script. Thanks, Dan On Nov 23, 1:05 pm, "Phlip" <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Dan Munk wrote: > > The application I am working on needs a nightly process to comb through > > the database and make periodic changes. > > > What is the best way to implement a script in order to leverage the > > existing database connection management and active record > > functionality?Tell the OS to periodically run a script using ''cron'', or the Task Manager, > or some derivative therof. Some are called ''at''. > > The script may run something like this: > > ruby script/runner "load(''my_batch.rb'')" > > my_batch.rb then contains a batch of Ruby, enjoying the complete Rails > context. IIRC. > > There might be other ways to invoke the runner script. --help didn''t confess > them. > > -- > Phlip > http://www.greencheese.us/ZeekLand<-- NOT a blog!!!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I think you''re looking for difficulties where there are none. The script run by cron (for example) will have its own database connection, just as each of your mongrels/fcgi listeners has one, and can use ActiveRecord just as your controllers would or you would from script/console. Fred -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Fred wrote:> I think you''re looking for difficulties where there are none. > The script run by cron (for example) will have its own database > connection, just as each of your mongrels/fcgi listeners has one, and > can use ActiveRecord just as your controllers would or you would from > script/console.I solved that one, and re-used the connection. I did it the extra-sick way. I wrote a private action, available only in non-production mode, and then I hit it with a simulated web browser. There''s a less-sick way, right? But all the pieces were just laying around, tempting me, saying "put me together like thiiiiis!!" -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
There are examples of how to use ActiveRecord outside of rails in the Rails Recipes book, it may be of use. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Dan Munk wrote:> Thanks Phlip, > > I have no problem with the scheduling of the script. I really want to > understand how people are writing the scripts themselves share the > existing database connections and use active record. For instance: > > 1. Periodic web service invocation. > 2. External script.This is Rails - you don''t share anything other than the database itself. Batch scripts and offload scripts run in their own separate process space unhindered by the Web facing application processes. NeilW --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---