Uploading files and writing them to server?

Where should I look for information on how to use Rails and Ruby to
accept the upload of a file and then to save that file to the file
system of my server?

I’m reading the “Uploading a file” section of Agile Web Dev with Rails,
but it’s geared toward saving the file in the database.

Any advice?

Thanks,
Jeff

If I remember correctly I used the AWDR example for the front-end and
did
the back-end piece after reading the file handling info from the
Programming
Ruby book - roughly in this section.

http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_io.html

If you haven’t tried the Ruby Sidebar, yet. It’s a great resource.

Google for the file_column plugin. It handles many of the minutae like
figuring out where in the filesystem to store the files, handling the
form field gracefully when it comes to updating the database record that
references it, etc., all through a one-line declaration in the model and
a string (varchar) field for the filename. And if they’re image files,
it’s got hooks into RMagick, ImageMagick, etc. for creating and caching
resized and otherwise processed versions of the image.

Not perfect but applicable to most situations and a whole lot easier
than reinventing the wheel.

Jeff C.man wrote:

Where should I look for information on how to use Rails and Ruby to
accept the upload of a file and then to save that file to the file
system of my server?

I’m reading the “Uploading a file” section of Agile Web Dev with Rails,
but it’s geared toward saving the file in the database.

Any advice?

Thanks,
Jeff

Thanks, Steve, that is exactly what I’m looking for!

I’ve just started playing with RMagick, as well. I have a model named
Image, which seems to be causing a namespace conflict. Is there a way I
can resolve that without changing my model?

Jeff

Steve K. wrote:

Google for the file_column plugin. It handles many of the minutae like
figuring out where in the filesystem to store the files, handling the
form field gracefully when it comes to updating the database record that
references it, etc., all through a one-line declaration in the model and
a string (varchar) field for the filename. And if they’re image files,
it’s got hooks into RMagick, ImageMagick, etc. for creating and caching
resized and otherwise processed versions of the image.

Not perfect but applicable to most situations and a whole lot easier
than reinventing the wheel.

Jeff C.man wrote:

Where should I look for information on how to use Rails and Ruby to
accept the upload of a file and then to save that file to the file
system of my server?

I’m reading the “Uploading a file” section of Agile Web Dev with Rails,
but it’s geared toward saving the file in the database.

Any advice?

Thanks,
Jeff