# Paperclip is making me crazy

**URL:** <https://www.ruby-forum.com/t/paperclip-is-making-me-crazy/183436>\
**Category:** Rails\
**Created:** [February 14, 2010, 2:15am UTC](https://www.ruby-forum.com/t/paperclip-is-making-me-crazy/183436 "2010-02-14T02:15:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2010, 2:15am UTC](https://www.ruby-forum.com/t/paperclip-is-making-me-crazy/183436/1 "2010-02-14T02:15:42Z")

</div>

seems pretty simple, my model…

has\_attached\_file :pic\_1, :styles =\> { :thumb =\> “120x90” },  
:url =\> “/:attachment/:id\_:style.:extension”,  
:path =\> “:rails\_root/public/system/:attachment/:id\_:style.:extension”

my view…

\<% form\_tag(:action =\> ‘create’, :html =\> { :multipart =\> true }) do -%\>  
Image  
\<%= file\_field ‘ad’, ‘pic\_1’ %\>  
\<%= submit\_tag ’ Save ', :class =\> ‘button’ %\>

and I save and the development.log shows expected…  
Processing Admin::AdsController#create (for 127.0.0.1 at 2010-02-13  
17:49:15) [POST]  
Parameters: {“html”=\>{“multipart”=\>“true”}, “commit”=\>" Save “,  
“ad”=\>{“salesprogram\_id”=\>“3”, “pic\_1”=\>“DSC01760.JPG”,  
“active”=\>“true”}, “action”=\>“create”, “authenticity\_token”=\>”-",  
“controller”=\>“admin/ads”}

But the SQL Insert for pic\_1\_file\_name, pic\_1\_file\_size,  
pic\_1\_content\_type and pic\_1\_updated\_at are all NULL

and I’ve googled and flailed and googled and flailed but I cannot make  
this work.

Can anyone toss me a bone here?

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2010, 2:53am UTC](https://www.ruby-forum.com/t/paperclip-is-making-me-crazy/183436/2 "2010-02-14T02:53:13Z")

</div>

Craig W. wrote:

> seems pretty simple, my model…
> 
> has\_attached\_file :pic\_1, :styles =\> { :thumb =\> “120x90” },  
> :url =\> “/:attachment/:id\_:style.:extension”,  
> :path =\> “:rails\_root/public/system/:attachment/:id\_:style.:extension”
> 
> my view…
> 
> \<% form\_tag(:action =\> ‘create’, :html =\> { :multipart =\> true }) do -%\>  
> Image  
> \<%= file\_field ‘ad’, ‘pic\_1’ %\>  
> \<%= submit\_tag ’ Save ', :class =\> ‘button’ %\>
> 
> and I save and the development.log shows expected…  
> Processing Admin::AdsController#create (for 127.0.0.1 at 2010-02-13  
> 17:49:15) [POST]  
> Parameters: {“html”=\>{“multipart”=\>“true”}, “commit”=\>" Save “,  
> “ad”=\>{“salesprogram\_id”=\>“3”, “pic\_1”=\>“DSC01760.JPG”,  
> “active”=\>“true”}, “action”=\>“create”, “authenticity\_token”=\>”-",  
> “controller”=\>“admin/ads”}
> 
> But the SQL Insert for pic\_1\_file\_name, pic\_1\_file\_size,  
> pic\_1\_content\_type and pic\_1\_updated\_at are all NULL
> 
> and I’ve googled and flailed and googled and flailed but I cannot make  
> this work.
> 
> Can anyone toss me a bone here?
> 
> Craig

Parameters: {“html”=\>{“multipart”=\>“true”}, “commit”=\>" Save ",

> “ad”=\>{“salesprogram\_id”=\>“3”, “pic\_1”=\>“DSC01760.JPG”,  
> “active”=\>“true”}, “action”=\>“create”, “authenticity\_token”=\>“-”,  
> “controller”=\>“admin/ads”} actually is not what you want to see in the params hash; the value at “pic\_1” should be a File object…

:html isn’t an option form\_tag understands; use use :multipart =\> true  
for your options hash.

> **[ActionView::Helpers::FormTagHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M001729)**
>
> Provides a number of methods for creating form tags that don't rely on an Active Record object assigned to the template like FormHelper does. Instead, you provide the names and values manually.

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2010, 6:21am UTC](https://www.ruby-forum.com/t/paperclip-is-making-me-crazy/183436/3 "2010-02-14T06:21:29Z")

</div>

On Sun, 2010-02-14 at 02:53 +0100, Paul H. wrote:

> > Image
> 
> Parameters: {“html”=\>{“multipart”=\>“true”}, “commit”=\>" Save ",
> 
> > “ad”=\>{“salesprogram\_id”=\>“3”, “pic\_1”=\>“DSC01760.JPG”,  
> > “active”=\>“true”}, “action”=\>“create”, “authenticity\_token”=\>“-”,  
> > “controller”=\>“admin/ads”} actually is not what you want to see in the params hash; the value at “pic\_1” should be a File object…
> 
> :html isn’t an option form\_tag understands; use use :multipart =\> true  
> for your options hash.  
> [ActionView::Helpers::FormTagHelper](http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M001729)

* * *

that’s what I get for trying to follow the examples supplied by the  
project…I actually caught it before I read your e-mail and indeed, you  
were right on the mark. The last time I did picture uploads, etc. was  
with Rails 1.2 & rmagick and everyone says how much better paperclip is  
which appears to be the case but I kept looking at the model code  
without ever suspecting that their sample code had the multipart =\> true  
that simply didn’t work.

Thanks

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.
