[Rails] One model handling two different file types

lisa-u
Tue, 13 Jun 2006 22:15:38 -0000

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.