Yu-Chieh’s Blog (Y.C. Chang)

Ruby on Rails / Rubygems / FullStack / Git / Mac notes.

How to Install and Use Ckeditor and Paperclip in Rails App

  • In paperclip requirement, Paperclip must have access to ImageMagick that must be installed. For Mac OS X, we could run this command with Homebrew.
1
$ brew install imagemagick
  • add this to your rails app Gemfile.
1
2
gem 'paperclip'
gem 'ckeditor'
  • then bundle it.
1
$ bundle
  • next, we should generate model for paperclip to store uplaoded files
1
$ rails generate ckeditor:install --orm=active_record --backend=paperclip
  • Don’t forget to rake db:migrate
1
$ rake db:migrate
  • Now, we need to mount it by editing your config/routes.rb
1
2
3
#...
mount Ckeditor::Engine => "/ckeditor"
#...
  • Add this in your app/assets/javascripts/application.js and make ckeditor working.
1
//= require ckeditor/init
  • In your form view, change f.text_area to f.cktext_area
1
2
3
4
5
<%= form_for @post do |f| -%>
#  ...
  <%= f.cktext_area :content, :class => "form-control" %>
#  ...
<% end -%>
  • done.

Comments