PDA

View Full Version : How to Enable FCKEditor in Rails


rob
May 15th, 2005, 06:02 PM
If you're designing an app that has a field for data that will appear on a webpage, you probably would like to have a nice interface for entering HTML-ized text there.

FCKEditor, for me anyway, fits that requirement nicely. It's easy to install into your views as well. Simply download FCKEditor from http://www.fckeditor.net/ and unzip it to a folder in your public directory called 'fckeditor'. The tarball will archive the files directly, so make sure you have the dir made and the tarball moved into it before you extract.

Once you're done, insert the following code into the rhtml file of the view you wish to have the editor:


<p><label for="item_description">Description</label><br/>
<script type="text/javascript" src="/fckeditor/fckeditor.js"></script>
<script type="text/javascript">
<!--
var oFCKeditor = new FCKeditor( 'item[description]' );
oFCKeditor.BasePath = '/fckeditor/';
oFCKeditor.Value = '<%= @item.description %>';
oFCKeditor.Create() ;
//-->
</script>
</p>


In the above example, a textbox is created called 'item[description]'. Name it appropriately for your situation.

This is just a basic setup though, you can add other variables to the oFCKeditor object to further customize it. For more information about the variables, see the documentation and samples that come with FCKEditor.

Robert

ezmobius
May 26th, 2005, 11:42 PM
This is cool! I'm going to try this out.

rob
May 31st, 2005, 10:24 PM
FCKEditor is wonderful. Hopefully a Ruby class will be written for it soon. If I wasn't about to embark on another open source Ruby project, I'd do it myself.

Rob

dcote
April 19th, 2006, 05:54 PM
Hello Rob,

I was able to integrate the FCKeditor in Typo, but I can't get the File Manager to work. I followed some tutorials on setting up the config files, but it didn't work. And I'm not sure which to use the ASP connectors or the PHP connectors for the file manager. Any suggestions?

-Dan Cote
webmaster of Pinellas Realtor Organization

rob
April 20th, 2006, 12:37 AM
I've had a tough time with the File Manager as well, and I did get it to work though on a project we did that needed it.

Make sure you have image uploads set to true in the config. Also, read the docs on file browsing (http://wiki.fckeditor.net/Developer%27s_Guide/Configuration/Built_in_File_Browser). You have to have a connector working. I prefer the PHP one until one for Ruby comes out :)

ezusbo
May 5th, 2006, 09:49 AM
I've had a tough time with the File Manager as well, and I did get it to work though on a project we did that needed it.

Make sure you have image uploads set to true in the config. Also, read the docs on file browsing (http://wiki.fckeditor.net/Developer%27s_Guide/Configuration/Built_in_File_Browser). You have to have a connector working. I prefer the PHP one until one for Ruby comes out :)

I had a go at this, out of necessity. I wrote a connector for Ruby on Rails which allows me to browse files, create folders, and upload files. Surprisingly (or not, considering this is Rails :D ), all it took were three small files. If anyone is interested, they can find the steps documented at http://public.ok2life.com/welcome/index/49.html