많은 Paperclip 자르기 자습서를 살펴본 결과 내가 잘못하고있는 것이 무엇인지 모르겠지만 제대로 작동하지 않습니다. 튜토리얼은 모두 구식이므로 궁금한 점이 있으시면 ...레일 용 종이 클립 사용자 정의 자르기 4
내가 사용한 최신 튜토리얼은 here입니다.하지만 오류는 설명이 아닙니다. 이 내 모바일 앱에 단지 서버 측 그대로
ActionView::MissingTemplate (Missing template profiles/failed to update, application/failed to update with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby]
내가 어떤 견해를 가지고 있지 않습니다 나는 Heroku가에 Rollback
과 뒤에
An error was received while processing: #<Paperclip::Error: There was an error processing the thumbnail for 1dc9f9eee29a7fd2f3f68e9c264b6d5420141014-13-v9mj79
를 얻을. 나는 후자의 오류가 롤백 후에 나타나기 때문에 관련이 없다고 추측하지만 나는 실수 할 수있다. 내 컨트롤러 내 모바일 앱에서 전송
데이터의 형식은 :
Parameters: {"profile"=>{"picture1_url"=>"http://a_url_here.com/sdfsdf.jpg", "crop_x"=>384, "crop_y"=>0, "crop_w"=>201, "crop_h"=>182}, "id"=>"123"}
그리고 마지막으로, 내 코드는 아래에 나열되어 있습니다. 내가 자르기를 방해하는 것은 무엇을 잘못하고 있습니까? 또는 프로세서를 사용하지 않기 위해 모델의 has_attached_file
에 명령을 전달할 수도 있습니까? 내 모델에서 이런 식으로 뭔가 :
# I tried this already and it didn't work but is there some other way to do this?
# Also keep in mind I will need to pass variables crop_y,crop_x, etc.
has_attached_file :picture1, styles: {
crop: "-crop '#{crop_w}x#{crop_h}+#{crop_x}+#{crop_y}"
}
내 실제 코드는 아래와 같습니다 :
내 모델 profile.rb
:
has_attached_file :picture1, styles: {
crop: {processors: [:cropper]}
}, url: "pictures/:facebook_id/:style/1:dotextension",
path: ":rails_root/public/:url"
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
내 컨트롤러 profiles_controller.rb
:
def profile_params
# I have other things I permit but only showing the crop values
params.require(:profile).permit(:crop_w,:crop_x,:crop_h,:crop_y)
end
내 프로세서 cropper.rb
:
module Paperclip
class Cropper < Thumbnail
def initialize(file, options = {}, attachment = nil)
super
@current_geometry.width = target.crop_w
@current_geometry.height = target.crop_h
end
def target
@attachment.instance
end
def transformation_command
crop_command = ["-crop","#{target.crop_w}x#{target.crop_h}+#{target.crop_x}+#{target.crop_y}"]
crop_command + super
end
end
end