سؤال

I have an error for my Paintings_controller wrong number of arguments (2 for 0).

 def create
@painting = Painting.new(painting_params)

I'm using Carrierwave I have an other controller (Attachements_controller) that uses Carrierwave but it doesn't have an error. I was wondering why for the "image" field it doesn't have an array {} like for the attachments field {"data"

paintings_controller "image"=>#<ActionDispatch::Http::UploadedFile:0x0000000456bc98 @tempfile=#<Tempfile:/tmp/RackMultipart20140305-28010-vof7in>,

attachement_controller

  "attachment"=>{"data"=>#<ActionDispatch::Http::UploadedFile:0x0000000096d728 @tempfile=#<Tempfile:/tmp/RackMultipart20140305-27719-1lw9xcn>,
 @original_filename="tumblr_mvhfvfHyWV1qkkdlto1_1280.jpg",

logs

Started POST "/paintings" for 127.0.0.1 at 2014-03-05 18:17:00 -0500
Processing by PaintingsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"pyZdz9eqYiEW+yEsXWy0gjh2o3UwA+AiwhAqxe98xHE=", "painting"=>{"title"=>"asdfa", "date(1i)"=>"2014", "date(2i)"=>"3", "date(3i)"=>"5", "dimension"=>"asfd", "medium"=>"asdfa", "image"=>#<ActionDispatch::Http::UploadedFile:0x0000000456bc98 @tempfile=#<Tempfile:/tmp/RackMultipart20140305-28010-vof7in>, @original_filename="tumblr_mmh9dpWBPb1qkkdlto1_500.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"painting[image]\"; filename=\"tumblr_mmh9dpWBPb1qkkdlto1_500.jpg\"\r\nContent-Type: image/jpeg\r\n">, "description"=>"asdfaf"}, "commit"=>"Create Painting"}
Completed 500 Internal Server Error in 62ms

ArgumentError (wrong number of arguments (2 for 0)):
  app/controllers/paintings_controller.rb:27:in `create'

paintings parameters

{"utf8"=>"✓",
 "authenticity_token"=>"pyZdz9eqYiEW+yEsXWy0gjh2o3UwA+AiwhAqxe98xHE=",
 "painting"=>{"title"=>"asdfa",
 "date(1i)"=>"2014",
 "date(2i)"=>"3",
 "date(3i)"=>"5",
 "dimension"=>"asfd",
 "medium"=>"asdfa",
 "image"=>#<ActionDispatch::Http::UploadedFile:0x0000000456bc98 @tempfile=#<Tempfile:/tmp/RackMultipart20140305-28010-vof7in>,
 @original_filename="tumblr_mmh9dpWBPb1qkkdlto1_500.jpg",
 @content_type="image/jpeg",
 @headers="Content-Disposition: form-data; name=\"painting[image]\"; filename=\"tumblr_mmh9dpWBPb1qkkdlto1_500.jpg\"\r\nContent-Type: image/jpeg\r\n">,
 "description"=>"asdfaf"},
 "commit"=>"Create Painting"}

attachements parameters

{"utf8"=>"✓",
 "authenticity_token"=>"K+mAtKBR0YJjfab28H4ecmTBL2AarqkPr3mHdgl9EQ4=",
 "attachment"=>{"data"=>#<ActionDispatch::Http::UploadedFile:0x0000000096d728 @tempfile=#<Tempfile:/tmp/RackMultipart20140305-27719-1lw9xcn>,
 @original_filename="tumblr_mvhfvfHyWV1qkkdlto1_1280.jpg",
 @content_type="image/jpeg",
 @headers="Content-Disposition: form-data; name=\"attachment[data]\"; filename=\"tumblr_mvhfvfHyWV1qkkdlto1_1280.jpg\"\r\nContent-Type: image/jpeg\r\n">},
 "commit"=>"Create Attachment"}

def painting_params
      params.require(:painting).permit(:title, :date, :dimension, :medium, :image, :description)
    end
هل كانت مفيدة؟

المحلول

Replace

version :thumb do 
process :thumb => [100, 100] 
end 

with

version :thumb do 
process :resize_to_fit => [100, 100] 
end

There was a problem setting the image

lib/carrierwave/mount.rb:179:in `image='  ## in stacktrace
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top