# paperclip is making me crazy

**URL:** <https://discuss.rubyonrails.org/t/paperclip-is-making-me-crazy/49341>\
**Category:** rubyonrails-talk\
**Created:** [February 14, 2010, 1:13am UTC](https://discuss.rubyonrails.org/t/paperclip-is-making-me-crazy/49341 "2010-02-14T01:13:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Craig\_White2](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@Craig\_White2](https://discuss.rubyonrails.org/u/Craig_White2)\
**Post date:** [February 14, 2010, 1:13am UTC](https://discuss.rubyonrails.org/t/paperclip-is-making-me-crazy/49341/1 "2010-02-14T01:13:47Z")

</div>

seems pretty simple, my model...

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

my view...

\<% form\_tag(:action =\> 'create', :html =\> { :multipart =\> true }) do -%\> &nbsp;&nbsp;\<label for="ad\_pic\_1"\>Image\</label\> &nbsp;&nbsp;\<%= 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] &nbsp;&nbsp;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

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [February 14, 2010, 1:53am UTC](https://discuss.rubyonrails.org/t/paperclip-is-making-me-crazy/49341/2 "2010-02-14T01:53:13Z")

</div>

Craig White wrote:

> seems pretty simple, my model...
> 
> has\_attached\_file :pic\_1, :styles =\> { :thumb =\> "120x90" }, &nbsp;&nbsp;:url =\> "/:attachment/:id\_:style.:extension", &nbsp;&nbsp;:path =\> ":rails\_root/public/system/:attachment/:id\_:style.:extension"
> 
> my view...
> 
> \<% form\_tag(:action =\> 'create', :html =\> { :multipart =\> true }) do -%\> &nbsp;&nbsp;\<label for="ad\_pic\_1"\>Image\</label\> &nbsp;&nbsp;\<%= 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] &nbsp;&nbsp;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)**
>
> Action View Form Tag Helpers 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.

---

<div class="post-metadata">

**Author:** ![Craig\_White2](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@Craig\_White2](https://discuss.rubyonrails.org/u/Craig_White2)\
**Post date:** [February 14, 2010, 5:20am UTC](https://discuss.rubyonrails.org/t/paperclip-is-making-me-crazy/49341/3 "2010-02-14T05:20:13Z")

</div>

> Craig White 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 -%\> \> \<label for="ad\_pic\_1"\>Image\</label\> \> \<%= 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](http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M001729)
