行番号3、つまり@ user.update_attributes(params [:user])のユーザーコントローラーのアップロード方法でエラーが発生したため、画像をアップロードできません。
私のアップロード方法コード-
def upload
@user = User.find_by_id(current_user.id)
if @user.update_attributes(params[:user])
flash[:notice] = "Successfully uploaded Image."
if params[:user][:avatar].blank?
redirect_to @user
else
render :action => 'crop'
end
else
render :action => 'new'
end
end
私のフォーム-
<%= form_for(:user, :url => {:action => 'upload'},
:html => {:multipart => true}) do |f| %>
<div class="inputs">
<p>
<%= f.label :avatar %>
<%= f.file_field :avatar %>
</p>
</div>
<div class="actions">
<%= f.submit "Upload" %>
</div>
<% end %>
私のユーザーモデル-
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,:recoverable,
:rememberable, :trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me, :avatar
has_attached_file :avatar,
:styles => { :small => "100x100#", :large => "500x500>" }
end
コマンドプロンプトでの出力-
identify: unable to open image `file': @ error/blob.c/OpenBlob/2498.
identify: no decode delegate for this image format `file' @ error/constitute.c /ReadImage/532.
Started POST "/users/upload" for 127.0.0.1 at 2012-12-06 13:28:17 +0530
Processing by UsersController#upload as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"mUPao835NCC8qXO553RJH50NWLhzQk03Z2G3Y0LwMYE=",
"user"=>{"avatar"=>#<ActionDispatch::Http::UploadedFile:0xa20a418 @original_filename="freedomking.jpg", @content_type="image/jpeg", @headers="Content-
Disposition: form-data; name=\"user[avatar]\"; filename=\"freedomking.jpg
\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20121206-3368-127uzt5>>}, "commit"=>"Upload"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
CACHE (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
(1.1ms) begin transaction
[paperclip] An error was received while processing:
#<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream20121206-7054-b
teogf.jpg is not recognized by the 'identify' command.>
[paperclip] An error was received while processing:
#<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream20121206-7054-b
teogf.jpg is not recognized by the 'identify' command.>
(0.1ms) rollback transaction