Ruby on Rails Ckeditor loses paperclip image assets on deploy -


i got ruby on rails website use ckeditor gem. https://github.com/galetahub/ckeditor

i have setup paperclip can upload images in editor. works without problems.

the problem when deploy cloud66 server ckeditor. makes it, uploaded images trough ckeditor deleted. (the links still same, images gone)

how solve this?

code: model > ckeditor > assets.rb

module ckeditor   class asset < activerecord::base     include ckeditor::orm::activerecord::assetbase     include ckeditor::backend::paperclip   end end 

model > ckeditor > attachment_file.rb

module ckeditor   class attachmentfile < ckeditor::asset     has_attached_file :data,                       url: "/ckeditor_assets/attachments/:id/:filename",                       path: ":rails_root/public/ckeditor_assets/attachments/:id/:filename"      validates_attachment_presence :data     validates_attachment_size :data, less_than: 100.megabytes     do_not_validate_attachment_file_type :data      def url_thumb       @url_thumb ||= ckeditor::utils.filethumb(filename)     end   end end 

model > ckeditor > picture.rb

module ckeditor   class picture < ckeditor::asset     has_attached_file :data,                       url: "/ckeditor_assets/pictures/:id/:style_:basename.:extension",                       path: ":rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension",                       styles: { content: "800>", thumb: "118x100#" }      validates_attachment_presence :data     validates_attachment_size :data, less_than: 2.megabytes     validates_attachment_content_type :data, content_type: /\aimage/      def url_content       url(:content)     end   end end 

config > initialers > assets.rb

rails.application.config.assets.version = "1.0"  # add additional assets asset load path # rails.application.config.assets.paths << emoji.images_path  # precompile additional assets. # application.js, application.css, , non-js/css in app/assets folder added. # rails.application.config.assets.precompile += %w( search.js ) rails.application.config.assets.precompile += %w( club.css admin.css ) rails.application.config.assets.precompile += %w( club.js admin.js )  rails.application.config.assets.precompile += ckeditor.assets rails.application.config.assets.precompile += %w(ckeditor/*) 

config > initialers > ckeditor.rb

ckeditor.setup |config|    require "ckeditor/orm/active_record"  end 

config > deploy.rb

# if want clean old releases on each deploy uncomment this: set :shared_children, shared_children + %w{public/ckeditor_assets} after "deploy:restart", "deploy:cleanup"  namespace :deploy   task :start, :roles => :app     run "touch #{current_path}/tmp/restart.txt"   end    task :stop, :roles => :app     # nothing.   end    desc "restart application"   task :restart, :roles => :app     run "touch #{current_path}/tmp/restart.txt"   end    after 'deploy:update_code'     #run "cd #{release_path}; rails_env=production rake db:create"      run "cd #{release_path}; rails_env=production rake db:migrate"     run "cd #{release_path}; rails_env=production rake db:seed"     run "cd #{release_path}; rails_env=production rake assets:precompile"      run "ln -s #{shared_path}/public/ckeditor_assets #{release_path}/public/ckeditor_assets"    end    desc "update crontab file"   task :update_crontab, :roles => :db     run "cd #{release_path} && whenever --update-crontab #{application}"     run "cd #{release_path}; tail -f log/cron_log.log"   end 

and got in routes.rb mount ckeditor::engine => "/ckeditor"

solution:

remove

url: "/ckeditor_assets/pictures/:id/:style_:basename.:extension", path: ":rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension", 

at picture model, change upload file system folder inside public folder, , prevent compiling wrong


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -