In my project I am using ckeditor as default HTML editor. One of the
strongest feature of ckeditor is that all its components are loaded from
server when started and can thus be easily extended. Which is also a
nightmare for rails developers because this problem cannot be solved by
assets pipeline especially if used as gem.

In ckeditor gem, which can be found on github
https://github.com/galetahub/ckeditor the problem was solved by adding
every single required file to app.config.assets.precompile which made
(in my case) assets compilation go from 1 minute to >5 minutes. What is
not acceptable.

Not until recently I found out assets:precompile rake task (why is this
so poor mentioned in documentation). Which can be added to every gem and
it is executed once when rake assets:precompile is invoked. So here is
my solution now:

(file lib/tasks/copy_assets.rb)
require 'fileutils'

desc "Copy all ckeditor files from gem's javascript folder to
public/assets/folder"
task "assets:precompile" do
p 'Copying ckeditor directory to public/assets folder *****'

input_dir = File.realpath( File.dirname( __FILE__ ) +
'/../../app/assets/javascripts/ckeditor')
output_dir = Rails.root.join('public/assets')
cp_r(input_dir, output_dir, verbose: true)
end

It works perfectly for me. Is there any problem to be expected except
the usual ones with browser caching?

by
TheR

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6208cde91e536159598f4f279b8017d9%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to