Hi All, I am new to this list and to rails. So far I am loving the way in which it is easy to put together web pages with a database backend. I would love to use the rails functionality (to do the sql queries) and then process the results using some very cpu intensuve tasks. The results will take far longer than it is viable to use a web browser to view the results. I would like to see the results on screen and write them to file. Is there a way of using rails functionality (specifically the model aspect) in a standalone ruby script or from the console? Many thanks Anthony --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Paul Mylchreest
2007-May-03 23:21 UTC
Re: How to run a cpu intensive ruby script with rails functionality
Hi Ant, You want to use AR outside of rails, no problem. <<====test.rb require ''active_record'' class TardisBase < ActiveRecord::Base self.abstract_class = true establish_connection :adapter => ''postgresql'', :host => ''localhost'', :username => ''me'', :password => ''secret'', :database => ''tardis'' end class TimeMachineBase < ActiveRecord::Base self.abstract_class = true establish_connection :adapter => ''postgresql'', :host => ''localhost'', :username => ''me'', :password => ''secret'', :database => ''timemachine'' end class Person < TardisBase end class Groovy < TimeMachineBase end Person.find(:all).each do |person| # whatever end ====test.rb Hope this helps On 3-May-07, at 19:09 , wrote:> > Hi All, > > I am new to this list and to rails. So far I am loving the way in > which it is easy to put together web pages with a database backend. > > I would love to use the rails functionality (to do the sql queries) > and then process the results using some very cpu intensuve tasks. The > results will take far longer than it is viable to use a web browser to > view the results. I would like to see the results on screen and write > them to file. > > Is there a way of using rails functionality (specifically the model > aspect) in a standalone ruby script or from the console? > > > Many thanks > > > Anthony > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ant
2007-May-04 09:03 UTC
Re: How to run a cpu intensive ruby script with rails functionality
Thanks Paul, that worked a real treat. After hours of google searching this has solved it in minutes. Anthony On May 3, 7:21 pm, Paul Mylchreest <paul.mylchre...-ee4meeAH724@public.gmane.org> wrote:> Hi Ant, > > You want to use AR outside of rails, no problem. > > <<====test.rb > require ''active_record'' > class TardisBase < ActiveRecord::Base > self.abstract_class = true > establish_connection :adapter => ''postgresql'', > :host => ''localhost'', > :username => ''me'', > :password => ''secret'', > :database => ''tardis'' > end > > class TimeMachineBase < ActiveRecord::Base > self.abstract_class = true > establish_connection :adapter => ''postgresql'', > :host => ''localhost'', > :username => ''me'', > :password => ''secret'', > :database => ''timemachine'' > end > > class Person < TardisBase > end > class Groovy < TimeMachineBase > end > > Person.find(:all).each do |person| > # whatever > end > ====test.rb > > Hope this helps > > On 3-May-07, at 19:09 , wrote: > > > > > Hi All, > > > I am new to this list and to rails. So far I am loving the way in > > which it is easy to put together web pages with a database backend. > > > I would love to use the rails functionality (to do the sql queries) > > and then process the results using some very cpu intensuve tasks. The > > results will take far longer than it is viable to use a web browser to > > view the results. I would like to see the results on screen and write > > them to file. > > > Is there a way of using rails functionality (specifically the model > > aspect) in a standalone ruby script or from the console? > > > Many thanks > > > Anthony--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---