Can't upload photo using paper clip
file-upload, ruby, ruby-on-rails, upload
Solution
I am not sure what `semantic_form_for` is, but with regular `form_for`, you have to explicitly say it's a multipart form.
<% form_for(@thing, :html => {:multipart => true}) do |f| %>
....
If you don't do this, the contents of your file upload fields won't be transmitted to the server. It's a HTML thing ;)
Problem
I used paper clip in my web application, I use this to make a new product: ``` <% semantic_form_for @product do |f| %> <% f.inputs do %> <%= f.input :title %> <%= f.input :price %> <%= f.file_field :photo %> <%= f.input :category , :include_blank => false %> <% end %> <%= f.buttons %> <% end %> ``` And this to show product: ``` <% semantic_form_for @product do |f| %> <%= image_tag @product.photo.url%> <% f.inputs do %> <%= f.input :title %> <%= f.input :price %> <%= f.file_field :photo %> <%= f.input :category , :include_blank => false %> <% end %> <%= f.buttons %> <% end %> ``` And his is my product.rb: ``` class Product < ActiveRecord::Base validates_presence_of :title, :price validates_numericality_of :price validates_uniqueness_of :title has_attached_file :photo attr_accessible :name, :category_id, :price, :title, :photo belongs_to :category has_many :order_items end ``` But after I upload the photo, it show my image path like this : http://localhost:3000/photos/original/missing.png It seems that it can't upload the photo with this error: ``` No route matches "/photos/original/missing.png" with ``` {:method=>:get}