在Rails 4中打破的Railscast图像裁剪器(Railscast image cropper broken in Rails 4)

编程入门 行业动态 更新时间:2024-10-20 16:05:41
在Rails 4中打破的Railscast图像裁剪器(Railscast image cropper broken in Rails 4)

这是我遵循的演练,它正在起作用:

http://railscasts.com/episodes/182-cropping-images

这是我升级到Rails 4后收到的错误

Started PATCH "/crop" for 127.0.0.1 at 2014-07-13 14:37:02 -0500 Processing by UsersController#crop as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"aTVhNXWWs6nyDnFbbqqHaKS90QafxVlLp4nGs8J4a8E=", "user"=>{"avatar"=>#<ActionDispatch::Http::UploadedFile:0x00000002146c28 @tempfile=#<Tempfile:/tmp/RackMultipart20140713-29032-2bjf1p>, @original_filename="74926649.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"74926649.jpg\"\r\nContent-Type: image/jpeg\r\n">}, "commit"=>"Crop Uploaded Image"} User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 188 ORDER BY `users`.`id` ASC LIMIT 1 (0.1ms) BEGIN Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/7492664920140713-29032-1guokao.jpg[0]' (0.2ms) ROLLBACK Completed 500 Internal Server Error in 72ms NameError - undefined local variable or method `crop_x' for #<User:0x00000002274a50>:

触发错误的行是:

def cropping? !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank? end

Here is the walkthrough I followed, which was working:

http://railscasts.com/episodes/182-cropping-images

Here is the error I'm receiving after upgrading to Rails 4

Started PATCH "/crop" for 127.0.0.1 at 2014-07-13 14:37:02 -0500 Processing by UsersController#crop as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"aTVhNXWWs6nyDnFbbqqHaKS90QafxVlLp4nGs8J4a8E=", "user"=>{"avatar"=>#<ActionDispatch::Http::UploadedFile:0x00000002146c28 @tempfile=#<Tempfile:/tmp/RackMultipart20140713-29032-2bjf1p>, @original_filename="74926649.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"user[avatar]\"; filename=\"74926649.jpg\"\r\nContent-Type: image/jpeg\r\n">}, "commit"=>"Crop Uploaded Image"} User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 188 ORDER BY `users`.`id` ASC LIMIT 1 (0.1ms) BEGIN Command :: identify -format '%wx%h,%[exif:orientation]' '/tmp/7492664920140713-29032-1guokao.jpg[0]' (0.2ms) ROLLBACK Completed 500 Internal Server Error in 72ms NameError - undefined local variable or method `crop_x' for #<User:0x00000002274a50>:

The line which triggers the error is:

def cropping? !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank? end

最满意答案

NameError - undefined local variable or method `crop_x' for #<User:0x00000002274a50>:

这意味着变量crop_x不存在。 确保您遵循教程并在模型顶部定义了属性访问器。

NameError - undefined local variable or method `crop_x' for #<User:0x00000002274a50>:

It means the variable crop_x does not exist. Make sure you followed the tutorial and defined the attribute accessor at the top of your model.

更多推荐

本文发布于:2023-07-06 07:35:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047366.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   Railscast   Rails   broken   cropper

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!