Hello, ...at least I''m pretty sure its called ActiveRecord. I have an app running on InstantRails 1.6 that will periodically call a ruby script in the /script folder. In the script, I use the same models to connect to my database as the ones in the rest of the app, but it doesn''t seem to work. I''m using "Model.connection.select_all(''sql statement'')" where Model is the name of the model. Do I have to call a special gem or something? Thanks, - Jeff Miller -- 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 -~----------~----~----~----~------~----~------~--~---
does it call the script as in system(script_name)? If so then that script would need to load up the whole AR framework somehow, at its start. -R On Thu, May 1, 2008 at 7:44 PM, Jeff Miller <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello, > ...at least I''m pretty sure its called ActiveRecord. I have an app > running on InstantRails 1.6 that will periodically call a ruby script in > the /script folder. In the script, I use the same models to connect to > my database as the ones in the rest of the app, but it doesn''t seem to > work. I''m using "Model.connection.select_all(''sql statement'')" where > Model is the name of the model. Do I have to call a special gem or > something? > > Thanks, > - Jeff Miller > -- > 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 -~----------~----~----~----~------~----~------~--~---
Jeff Miller wrote:> Hello, > ...at least I''m pretty sure its called ActiveRecord. I have an app > running on InstantRails 1.6 that will periodically call a ruby script in > the /script folder. In the script, I use the same models to connect to > my database as the ones in the rest of the app, but it doesn''t seem to > work. I''m using "Model.connection.select_all(''sql statement'')" where > Model is the name of the model. Do I have to call a special gem or > something?you need to include your "environment.rb" sticking this line; require File.expand_path(File.dirname(__FILE__) + "/../config/environment") at the top of your file should load up rails, giving you access to all of your models. -- 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 -~----------~----~----~----~------~----~------~--~---
That worked great! Thanks very much! -- 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 -~----------~----~----~----~------~----~------~--~---
I think another way to do this is with script/runner. I think you can use script runner in place of sh or tcsh (e.g. #! script/runner as the first line of the script file) and that is supposed to load the environment. See script/runner -help. I haven''t tried it myself yet, but was just learning about it. On May 2, 4:35 pm, Jeff Miller <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> That worked great! Thanks very much! > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---