Automating a ruby script

I have been working on an application that takes a text file and
parses information from it. I have the script in my script folder,
and can run it if I enter ‘script/parser file.txt’. I am using the
‘attachment_fu’ plug-in to upload the text file to my public folder
(admittedly not the best place to keep raw data, but I will work that
out in time). Once I have that file uploaded, and verified it using
the ‘validates_as_attachment’, how do I get the script to
automatically parse the file?

Would it be possible to create a helper that runs a console command?
It seems possible, but not the best way. Does anyone have a better

Thank you so much for any help you can give. I have been racking my
brain trying to figure this out.

Is there any particular reason that you wrote the script as an
external command instead of simply write that code as a class that you
can call your parsing methods on?

class AttachmentParser
def parse(file)
…your parsing code here…

You could put this class either in a directory where Rails will load
it automatically or you can require it wherever you want to do your

The parser was originally set up to run from the Terminal, but now I
want it automated. Your way worked perfectly, and I even added the
method to be called from the script, and now it will work either way.
Thanks again.

On a different note, you don’t happen to know how to link to an index
view in another folder?