o
user= User.find(6) user.name="fuck" user.save
问题已经解决了。 我原来是在 UBUTU11.04 上下载 编译安装。将/usr/local 相关文件全部删除 然后直接 sudo apt-get install imagemagick。安装完成后,正常了。
identify 命令结果应该也正常 joinall@nxbbs-server:/nxbbs$ convert logo: kala.jpg joinall@nxbbs-server:/nxbbs$ identify kala.jpg kala.jpg GIF 640x480 640x480+0+0 8-bit sRGB 256c 31.7KB 0.000u 0:00.000
joinall@nxbbs-server:/nxbbs/bbs$ which convert /usr/local/bin/convert 在 development.rb 里已经加代码: Paperclip.options[:command_path] = "/usr/local/bin/"
在 update 时报错:
Started PUT "/users/10002" for 192.168.0.7 at 2012-11-11 16:16:35 +0800
Processing by UsersController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"ipIII+Yr0KUqhyWq1XYLVIqIPUTEQC4k/VSWu6lREfQ=", "user"=>{"netname"=>"猎鹰", "avatar"=>#<ActionDispatch::Http::UploadedFile:0xab70a84 @original_filename="20120803160251_72775.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"20120803160251_72775.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/tmp/RackMultipart20121111-1031-1noi5hp>>}, "commit"=>"修改", "id"=>"10002"}
User Load (1.7ms) SELECT "USERS".* FROM "USERS" WHERE "USERS"."ID" = :a1 AND ROWNUM <= 1 [["id", 10002]]
Command :: identify -format %wx%h '/tmp/20120803160251_7277520121111-1031-1yjenhp.jpg[0]'
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: /tmp/20120803160251_7277520121111-1031-1yjenhp.jpg is not recognized by the 'identify' command.>
Command :: identify -format %wx%h '/tmp/20120803160251_7277520121111-1031-1yjenhp.jpg[0]'
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: /tmp/20120803160251_7277520121111-1031-1yjenhp.jpg is not recognized by the 'identify' command.>
Command :: identify -format %wx%h '/tmp/20120803160251_7277520121111-1031-1yjenhp.jpg[0]'
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: /tmp/20120803160251_7277520121111-1031-1yjenhp.jpg is not recognized by the 'identify' command.>
Redirected to http://192.168.0.5:8888/users/10002/edit
Completed 302 Found in 53ms (ActiveRecord: 1.7ms)
def update
@user = current_user
if params[:user][:netname] != @user.netname
@user.netname = params[:user][:netname]
end
if params[:user][:avatar]
@user.avatar = params[:user][:avatar]
end
if @user.save
#@user.update_attribute("netname",params[:user][:netname])
flash[:notice] = "用户信息修改成功!"
redirect_to user_path(@user)
else
flash[:notice] = "未知错误,保存失败!"
redirect_to edit_user_path(@user)
end
end
#用户图像-------------------------------------------------------------------------------------------- attr_accessible :avatar has_attached_file :avatar, :styles => { :big => "120x120>", :normal => "48x48#", :small => "16x16>" }, :default_sytle => "normal", :default_url => "/assets/:style_avatar.png", :url => "/uploadfiles/:class/:attachment/:id/:basename/:style.:extension", :path => ":rails_root/public/uploadfiles/:class/:attachment/:id/:basename/:style.:extension"
validates_attachment_content_type :avatar, :content_type =>[ "image/gif",'image/png','image/x-png','image/jpeg','image/pjpeg','image/jpg'], :message => "头像文件需要是图片格式。如:png,jpg.jpeg,gif 等"
??
木有人踩我?