Note that there are some explanatory texts on larger screens.

plurals
  1. POPaperclip not saving, no errors
    primarykey
    data
    text
    <p>Am stumbled - went through docs, tutorials, etc, and am not sure what I am doing wrong.</p> <p>Another model in the project is set up for Paperclip and is functional when tested. It saves and retrieves attachment file info into the database, and puts file into a subfolder inside public/system. I basically copied the relevant code over toward the model I am working on</p> <p>The model has the following line:</p> <pre><code>has_attached_file :document </code></pre> <p>The table, which model is linked to, has necessary columns:</p> <pre><code>document_file_name document_content_type document_file_size document_updated_at </code></pre> <p>The edit view has this (in haml):</p> <pre><code>%h1 Knowledge Base: Edit Article = message_block :on =&gt; @article - form_for(@article, :url =&gt; knowledge_base_article_path(@article), :html =&gt; {:multipart =&gt; true}) do |f| #knowledgebase.clearfix %label Upload KB Document: %br = f.file_field :document - if @article.document.exists? %p = link_to "Current KB Attachment", @article.document.url %p = f.check_box :remove_document &lt;br&gt; = render :partial =&gt; "form", :locals =&gt; {:f =&gt; f} = submit_tag "Save changes" = link_to "Cancel", knowledge_base_article_path(@article) </code></pre> <p>When I save the model instance, I can see in log that Rails is aware of the file I am trying to upload: </p> <pre><code>Processing KnowledgeBase::ArticlesController#update (for 127.0.0.1 at 2010-11-18 19:21:01) [PUT] Parameters: {"article"=&gt;{"document"=&gt;#&lt;File:/var/folders/EZ/EZKwznNSGq4PAI4ll9NUD++++TI/-Tmp-/RackMultipart20101118-58632-19nvbc8-0&gt;, "question"=&gt;"Craig's Sandbox", "active"=&gt;"0", "answer"=&gt;"Nothing here, this is to test attachment functionality"}, "commit"=&gt;"Save changes", "action"=&gt;"update", "_method"=&gt;"put", "authenticity_token"=&gt;"MfH6RgLAQLnRBuf9WxgqWA+mIrDoBtYF+d4MW5DNCC0=", "id"=&gt;"886", "controller"=&gt;"knowledge_base/articles"} </code></pre> <p>Yet the db values are not updated at all for the four <code>document_</code>* columns, they remain NULL. The other columns in same table are updated fine. </p> <p>Just to be sure the db columns are named correctly, I changed db columns to something else and got error upon hitting the view, so I know the db columns are named correctly.</p> <p>To test attachment retrieval, I manually created subfolders inside public/system (where the attachment would have went when model instance is saved), and also manually modified the four <code>document_</code>* columns in the table. I then went to the same view above, and it did show the correct attachment in question. </p> <p>I noticed that I am also unable to remove the attachment when "remove_document" is checked. The db values for <code>document_</code>* remains unchanged. </p> <p>It is as if read operation on those 4 columns work, but the write operation does not (though I am able to have Rails modify other columns in the same table if I modify something in the model instance on the edit view page). </p> <p>Any ideas what I could be doing wrong here? I am sure I missed something obvious.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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