你如何将ckeditor与Paperclip集成以便它可以上传图像文件?

dmo*_*oly 12 plugins ruby-on-rails paperclip ckeditor

你如何得到http://github.com/galetahub/rails-ckeditor工作,你可以上传图像文件?我不认为我会使用s3存储...

任何帮助,将不胜感激.

小智 7

是的你可以.我假设您已经为S3设置了回形针.所以你只需在你的模型目录(app/model/ckeditor /)中编辑picture.rb和attachement_file.rb并替换这些行

  has_attached_file :data,
                    :url => "/ckeditor_assets/attachments/:id/:filename",
                    :path => ":rails_root/public/ckeditor_assets/attachments/:id/:filename"
Run Code Online (Sandbox Code Playgroud)

与您的papeclip版本has_attached_file:

  has_attached_file :data, :styles => { :content => '575>', :thumb => '80x80#' },
    :storage => :s3, :s3_credentials => "#{Rails.root}/config/s3.yml", :path => ":attachment/:id/:style.:extension",
    :url => ":s3_domain_url"
Run Code Online (Sandbox Code Playgroud)

而已.顺便说一句:这是Rails 3的例子.