Ckeditor With Rails4 on Heroku

I push rails101_groupme to heroku today. The project doesn’t have access control and i18n. I use cancan gem to do access authorization and default i18n mechanism. Besides, i also upgrade twitter bootstrap to 3.0.0.

When i push to heroku, i get stuck in ckeditor’s rails 4 compatibility and git issue. After googling i solve it finally.

Fail to fetch gem from git

Error message like this

1
2
3
4
Fetching git@github.com:Compass/compass-rails.git
Host key verification failed.
fatal: The remote end hung up unexpectedly
Git error: command `git clone 'git@github.com:Compass/compass-rails.git' "/tmp/build_1xa9

Because git@github.com use SSH to communication, it requires authentication. Your gemfile may contain some gems like

Old
1
gem "compass-rails", :git => "git@github.com:Compass/compass-rails.git", :branch => "rails4"

Change to

New
1
gem "compass-rails", :github => "Compass/compass-rails", :branch => "rails4"

Miss assets in rails 4

Very helpful link. Put below in your production.rb

production.rb
1
2
3
...
config.serve_static_assets = true
...

Ckeditor doesn’t show correctly

Reference to link and link2. Because ckeditor will read the assets file without digest postfix. My solution is
Add a rake file to create nondigest file of all ckeditor assets.

ckeditor.rake
1
2
3
4
5
6
7
8
9
10
require 'fileutils'
desc "Create nondigest versions of all ckeditor digest assets"
task ckeditor: :environment do
  fingerprint = /\-[0-9a-f]{32}\./
  for file in Dir["public/assets/ckeditor/**/*"]
    next unless file =~ fingerprint
    nondigest = file.sub fingerprint, '.'
    FileUtils.cp file, nondigest, verbose: true
  end
end

Execute rake ckeditor after rake assets:precompile

1
2
rake assets:precompile
rake ckeditor

Comments