One model handling two different file types

Hi.

I’ve gotten stuck again, this time at having one model handling 2
different file types.

My model, Logfile has fields id and filename. It also has a file=
method to handle an uploaded test file.

What I want is to be able to upload either a text file or zipfile. The
zipfile contains text files, and I’d like to save each text file within
this zipfile as a Logfile. Is possible to handle both within Logfile?
Or should I handle them in LogfileController?

Would I have to have two of these (one for txt and another for zip)?
Upload File:
<%= file_field(:logfile, ‘file’) %>

If I handle this in the controller, would I have to create a separate
hash for the file alone? I ask this because using
@uploaded_file = params[:logfile]['file]
within LogfileController has given me a nil.

Also, where can I find documentation for file= ? (It’s kind of a hard
keyword to search for)

Sorry for all the questions and sorry for being such a newbie. I really
want to take advantage of the Ruby way, but my brain is all Java-fied.

lisa-u wrote:

My model, Logfile has fields id and filename. It also has a file=
method to handle an uploaded test file.

Oops! I meant “text file”.

Never mind. My design worked (sort of). I just needed to maintain my
variables with similar names. I’m a horrible at naming.

What happened was I uploaded either txt or zip through a web form,
handled each file accordingly (sorted by @uploaded_file.content_type)
and created a Logfile (or looped to create many logfiles, in the case of
the zipped file).

I’m still having a bit of trouble saving the file to the correct
location without any errors, but I’m sure I can handle that.