1

我正在使用 CKEditor-rails ( https://github.com/tsechingho/ckeditor-rails ),我在上传图片时遇到了一些问题。上传照片的模型如下所示:

class Ckeditor::Picture < Ckeditor::Asset
  has_attached_file :data,
                    :styles => { :content => '800>', :thumb => '118x100#' },
                    :s3_credentials => "#{Rails.root}/config/s3.yml",
                    :bucket => "********"

  validates_attachment_size :data, :less_than => 2.megabytes
  validates_attachment_presence :data

  def url_content
    url(:content)
  end
end

当我使用CKEditor上传图片时,图片的URL是一个路径,格式为“/system//图片/数据/000/000/016/content/**.jpg”。

看起来图像甚至没有被上传。

4

1 回答 1

0

我在我的模型中使用了这个设置,试试这个。

has_attached_file :logo, :styles => { :orig => "300x400>",
                        :thumb => {:geometry => "80x58#", :format => :png},
                        :full => {:geometry => "#{SEARCH_IMAGE_WIDTH}x#{SEARCH_IMAGE_HEIGHT}#", :format => :png, :jcrop => true},
                        :cropped => {:geometry => "#{LOGO_WIDTH}x#{LOGO_HEIGHT}>", :jcrop => true, :format => :png} },
                        :storage => :s3,
                        :s3_credentials => "#{Rails.root.to_s}/config/s3.yml",
                        :path => "logos/:id/:style/:basename.:extension",
                        :bucket => "photo/#{Rails.env}/system"
于 2013-02-23T18:43:28.507 回答