On 7 July 2012 17:21, David M. <li...@ruby-forum.com> wrote:
> Hassan Schroeder wrote in post #1067807:
>> On Sat, Jul 7, 2012 at 8:11 AM, David M. <li...@ruby-forum.com> wrote:
>>
>>> Currently the model handles those files, saves some metadata (the
>>> extention and orig filename) then saves the file to the hard drive. Next
>>> it converts the doc and docx files to plain text and saves the output to
>>> a txt file.
>>>
>>> My problem is I want to copy the plain text contents of those txt files
>>> to the :body field in my database, but by the time those files are
>>> written no more changes can be sent to the data base (because all the
>>> file handling is done in after_save)
>>
>> Wouldn't the obvious answer be to do the file handling in before_save?
>>
>> And is there a reason to write the text to a file in the first place if
>> you're
>> just going to save it in the DB?
>>
>> --
>> Hassan Schroeder ------------------------ hassan.schroe...@gmail.com
>> http://about.me/hassanschroeder
>> twitter: @hassan
>
> The file handling code I have doesn't seem to function unless it happens
> after_save, I'm not sure why that is.
>
> The idea about saving the txt files to disk is so that the client can
> download them via ftp.

With files it is often better just to store them in files and not in
the database.  Certainly they should not be stored in both file and
database.

Colin

-- 
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en-US.

Reply via email to