Integrating a Rich Text Editor into Active Scaffold

May 28, 2009
In recent weeks we have had a increase in requests for a MS Word like text editor (WYSIWYG) in our content management systems (CMS).

To speed up development times we often use Active Scaffold (AS) to help with our backend functionality. AS unfortunately doesn't come with a built in editor therefore we needed to integrate a WYSIWYG into it.

After a little google'in we found FCK Editor which is an impressive, well known and well managed WYSIWYG editor.

After a little tweaking in both AS and FCK editor this became the perfect solution.

The below shows the steps needed to integrate FCK Editor into Active Scaffold (Rails 2.3.2)

1) Once you have installed the easy-fckeditor plugin you need to run

   1  rake fckeditor:install

2) Then include the FCK Editor Javascript into your layout

   1  <%= javascript_include_tag :fckeditor %>

3) Include the following into the relevant controller

   1  config.create.multipart = true
   2  config.update.multipart = true

4) Config the form column in the helpers to display the FCK Editor (replace txt_area with your relevant column name)

   1  def txt_area_form_column(record, input_name)
   2     fckeditor_textarea(:record, :txt_area, :toolbarSet => 'Default', :name=> input_name,  :width => "740px", :height => "200px")
   3   end
   4  
   5   def txt_area_column(record)
   6     sanitize(record.txt_area)
   7   end

And thats it you should now be the proud owner of a WYSIWYG Editor in you ruby on rails application.

Bookmark and Share

Why Ruby on Rails ?

Ruby On Rails Logo
Find out how Ruby on Rails could save your company time & money!

Latest News

Amazon S3 in AWS Management Console Demo

June 10, 2010
Amazon announce that the AWS Management Console now provides a simple and intuitive web interface for managing your Amazon S3 resources.
Read more »

Open Source ?

open source technology
Find out why savantis use open source technology & how this can benefit you !