Cron is a fine approach if you want an action to be based on time.
If you want some action to be based on some user action, just
redirect_to it after the file is uploaded.
If you're using Cron, it's likely best to use a rake task.  Quite
easy, if you haven't done it before. Much like writing a little
controller.  This gives you access to the Rails stack without dealing
with your web server.
You can call the rake task from your crontab file.  Don't forget to
use absolute paths and a subshell.  I do it like this (after the time
declaration):
system_user_name (cd /path/to/rails/app; /usr/bin/rake rake_task_name)
I'd be looking at the File class if you're having trouble with your
particular file encoding.
Worst case there is that you have to use "system
some_unix_utility_that_will_convert_your_file some_arguments" to do
some converting before you open the file using Ruby.
The rest should just be string manipulation and normal record creation
the Rails way.

On Feb 22, 9:45 pm, bongoman <[email protected]> wrote:
> Hi there
>
> I have a Rails app running that needs to have it's database
> periodically updated from an upload of a text file.
>
> The data file is in UIEE format and I'm working on a Ruby script that
> parses the file and inserts the data into MySQL. That should be OK I
> think at this stage.
>
> However I need to automate this process - basically the client is
> uploading the UIEE file to a prescribed directory on the remote
> server. I then either need to detect whether there has been a fresh
> upload OR rely on cron to look into the directory and then parse the
> fresh file (if present).
>
> Am I on the right track looking at cron to do this? Maybe I'm better
> building an admin page where the user can manually trigger the running
> of the database update script? Or is there another unix command that
> can detect a change in a directory and thereby trigger the script?
>
> Any clues on how best to approach this situation would be
> appreciated...
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to