Note that there are some explanatory texts on larger screens.

plurals
  1. POPaperclip usage with form_tag in rails
    primarykey
    data
    text
    <p>I'm attempting to get paperclip working with a rails application, and have been unsuccessful so far. Please help me do so; I've included what I think to be the relevant information below, and will be responsive to questions.</p> <p>It's saving the name of an uploaded photo to the database, and seems to have a path:</p> <pre><code>[13] pry(main)&gt; Order.last Order Load (0.3ms) SELECT "orders".* FROM "orders" ORDER BY "orders"."id" DESC LIMIT 1 =&gt; #&lt;Order id: 22, quantity: 13, created_at: "2013-02-03 21:47:46", updated_at: "2013-02-03 21:47:46", user_id: 8, drawing_file_name: "friends.jpg", drawing_content_type: nil, drawing_file_size: nil, drawing_updated_at: nil&gt; [14] pry(main)&gt; Order.last.drawing Order Load (0.2ms) SELECT "orders".* FROM "orders" ORDER BY "orders"."id" DESC LIMIT 1 =&gt; /system/orders/drawings/000/000/022/original/friends.jpg </code></pre> <p>However:</p> <ul> <li>I can't find anything under that path, on my system or within the application files</li> <li><p>From other answers like <a href="https://stackoverflow.com/questions/4221076/paperclip-not-saving-no-errors">these</a>, it seems like my params hash passed from the form should have a lot more content; right now, it's only a string name, which seems too short</p> <pre><code>[2] pry(#&lt;OrdersController&gt;)&gt; params =&gt; {"utf8"=&gt;"✓", "authenticity_token"=&gt;"eTInEukPQ84uIw3TPIdI+u0zo49dQlY68gxrodIoPdA=", "quantity_field"=&gt;"34", "drawing_field"=&gt;["friends.jpg"], "supplier_list"=&gt;["1", "2"], "commit"=&gt;"Create order", "multipart"=&gt;"true", "action"=&gt;"create", "controller"=&gt;"orders"} </code></pre></li> </ul> <p>order.rb</p> <pre><code>class Order &lt; ActiveRecord::Base attr_accessible :quantity, :drawing has_attached_file :drawing, :url =&gt; "/:attachment/:id/:style/:basename.:extension", :path =&gt; ":rails_root/public/:attachment/:id/:style/:basename.:extension" </code></pre> <p>_form.html.erb</p> <pre><code>&lt;%= form_tag :action =&gt; 'create', :controller =&gt; 'orders', :multipart =&gt; true do %&gt; .... &lt;div&gt; &lt;%= file_field :order, :drawing %&gt; &lt;%= label_tag :drawing, 'Attach drawing here' %&gt; &lt;/div&gt; &lt;%= submit_tag "Create order", :disable_with =&gt; "Creating..." %&gt; </code></pre> <p>orders_controller.rb</p> <pre><code>def create #binding.pry @order = Order.new#(params[:order]) @order.quantity = params[:quantity_field] @order.user_id = current_user.id @order.drawing = params[:order][:drawing] did_order_save = @order.save .... </code></pre> <p>When I try to make a new order, I get:</p> <pre><code> Started POST "/orders?multipart=true" for 127.0.0.1 at 2013-02-05 20:07:20 -0800 Processing by OrdersController#create as HTML Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"eTInEukPQ84uIw3TPIdI+u0zo49dQlY68gxrodIoPdA=", "quantity_field"=&gt;"334", "order"=&gt;{"drawing"=&gt;"profileBox.png"}, "supplier_list"=&gt;["1"], "commit"=&gt;"Create order", "multipart"=&gt;"true"} User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = 'kGRbFvLaYseFaHvRR6sy6w' LIMIT 1 Completed 500 Internal Server Error in 19882ms Paperclip::AdapterRegistry::NoHandlerError (No handler found for "profileBox.png"): app/controllers/orders_controller.rb:54:in `create' </code></pre> <p>I have paperclip/imagemagick installed, have done the migration and confirmed that drawing_file_name etc. are in the database, and have restarted server since. </p>
    singulars
    1. This table or related slice is empty.
    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