Ruby on Rails Saturday, July 7, 2012

Hassan Schroeder wrote in post #1067807:
> On Sat, Jul 7, 2012 at 8:11 AM, David M. <lists@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.schroeder@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.

--
Posted via http://www.ruby-forum.com/.

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

No comments:

Post a Comment