Ruby on rails 未初始化常量Blitline Gem
我在使用Blitline处理图像时遇到问题。我已经将gem添加到我的gem文件中,等等。。。但在rails控制台中,当我尝试测试它时,会出现以下错误:Ruby on rails 未初始化常量Blitline Gem,ruby-on-rails,ruby,ruby-on-rails-4,blitline,Ruby On Rails,Ruby,Ruby On Rails 4,Blitline,我在使用Blitline处理图像时遇到问题。我已经将gem添加到我的gem文件中,等等。。。但在rails控制台中,当我尝试测试它时,会出现以下错误: Loading development environment (Rails 4.0.1) 2.0.0p353 :001 > blitline_service = Blitline.new NameError: uninitialized constant Blitline 这与我在应用程序中尝试通过模型使用blitline时遇到的错误相
Loading development environment (Rails 4.0.1)
2.0.0p353 :001 > blitline_service = Blitline.new
NameError: uninitialized constant Blitline
这与我在应用程序中尝试通过模型使用blitline时遇到的错误相同
NameError in DrawingsController#create
uninitialized constant Drawing::Blitline
完整型号代码
class Drawing < ActiveRecord::Base
scope :published, -> { where(published: true) }
attr_accessible :image, :title, :user_id, :week_id, :key, :published, :safe_for_kids
#=mount_uploader :image, DrawingUploader
belongs_to :week
belongs_to :user
def image_name
File.basename(image.path || image.filename) if image
end
before_save :run_blitline_job
private
def run_blitline_job
filename = File.basename(image, '.*')
# self.title ||= sanitize_filename(filename).titleize # set default name based on filename
filename_with_ext = File.basename(image)
key = "uploads/thumbnails/#{SecureRandom.hex}/#{filename_with_ext}"
bucket = ENV["S3_BUCKET"]
images = blitline_job(image, bucket, key)
self.image = images['results'][0]['images'][0]['s3_url'] # extracts s3_url from blitline's ruby hashes
end
def blitline_job(original_image, bucket, key)
blitline_service = Blitline.new
blitline_service.add_job_via_hash({ # New add job method in Blitline gem 2.0.1. Messy.
"application_id" => ENV['BLITLINE_APPLICATION_ID'],
"src" => original_image,
"functions" => [{
"name" => "watermark", # watermark the image
"params" => { "text" => "oh hai" },
"functions" => [{
"name" => "resize_to_fill", # resize after watermark
"params" => { "width" => 200, "height" => 200 },
"save" => {
"image_identifier" => "MY_CLIENT_ID", # Not sure what this is for
"s3_destination" => { "key" => key, "bucket" => bucket } # push to your S3 bucket
}
}]
}]
})
return blitline_service.post_jobs
end
end
类绘图感谢您的帮助……我想您只是错过了一个要求:要求“闪电线”就是这样。我可以发誓在问这个问题之前我已经做过了,但显然不是。谢谢