Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>The big problem is that my server does not permit my application to write files locally, and these plugins all seem to want to create a Tempfile.</p> </blockquote> <p>Yes it does, or you wouldn't be able to upload the files at all.</p> <p>Rails itself creates tempfiles if the uploaded file is larger than 15k or so.</p> <pre><code>&lt;%= f.file_field :file %&gt; .... file_param = params[:upload][:file] </code></pre> <p>As soon as you upload something bigger than 15k, <code>params[:upload][:file]</code> is going to be an <code>ActionController::UploadedTempFile</code>.</p> <p>What's the difference? Rails is likely writing it's tempfiles to the global temp directory (which everyone can write to) but the plugins are probably trying to write to RAILS_ROOT/tmp, which your server disallows. The good news is you can just configure those things to use a different temp dir so they can write their tempfiles, and it should all work.</p> <p>For example, <a href="http://github.com/technoweenie/attachment_fu/tree/master/lib/technoweenie/attachment_fu.rb#L4" rel="nofollow noreferrer">attachment_fu's default temp path is under rails root.</a>. You should be able to change it like this:</p> <pre><code>Technoweenie::AttachmentFu.tempfile_path = Dir::tmpdir </code></pre> <p>**PS: pulling the file data straight out of the params and putting it into the database may still be the best way to go. I personally dislike attachment_fu and it's ilk, as they try to do too many things, but either way, it's very useful to know about how the whole uploaded file/temp file thing works in rails :-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload