Hi All, I want to write a ruby script that I can launch via a cron job once a night. This script would need to access a rails app that''ve created, it would need to render a xml builder view in the app to text and save the text as a xml file. I''ve already written the rails view and and I have corresponding controller action. Is it possible to run a rails controller action from a ruby file and saves its output to a file? Does anyone have any examples of how one might do this? If you can''t run a controller action, is there anyway to render a rails view to text from a ruby script? Thanks in advance, Janak --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
j s wrote:> Hi All, > > I want to write a ruby script that I can launch via a cron job > once a night. > > This script would need to access a rails app that''ve created, it > would need to render a xml builder view in the app to text and save > the text as a xml file. > > I''ve already written the rails view and and I have corresponding > controller action. > > Is it possible to run a rails controller action from a ruby file > and saves its output to a file? Does anyone have any examples of how > one might do this? If you can''t run a controller action, is there > anyway to render a rails view to text from a ruby script?For running an action from a script take a look at script/runner. To save the contents of a rendered view to a file you can either turn on caching for that action and grab that resulting view or you can use render_to_string and then save that string to a file explicitly. -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---