Scott Rutherford

Life on and off the Rails

 

FCKEditor Plugin for Rails

August 7th, 2006

Following on from my experiences with FCKEditor and Rails, I decided to wrap the whole thing up as a plugin. This can be downloaded here or installed using the plugin install command, see this post

It basically combines and extends the following pieces of work:

  1. Integrate FCKEditor with your Ruby on Rails application By Joshua M Charles
  2. Implementation details for FCKEditor integration with Ruby on Rails
  3. FCKEditor On Rails

The end result is the editor with a working resource manager and a set of helpers that allow use with both AJAX and basic HTML forms.

Install

  1. Download and extract the tar in your plugins directory
  2. Run ‘rake fckeditor:install’ from the root of your rails application
  3. Add <%= javascript_include_tag “fckeditor/fckeditor” %> to the layout / head of the page you wish to use the editor on.
  4. Use the editor as shown below

Using with AJAX

<%= form_remote_tag :url => { :action => 'view', :id => @comment }, 
                    :before => fckeditor_before_js('comment', 'comment') %>

    <div id="<%= fckeditor_div_id('comment', 'comment') %>">
        <%= fckeditor_textarea( "comment", "comment", :ajax => true ) %> 
    </div>
<% end_form_tag %>

Using with HTML

<%= form_tag :action => 'new' %>

    <div id="<%= fckeditor_div_id('comment', 'comment') %>">
        <%= fckeditor_textarea( "comment", "comment" ) %> 
    </div>
<% end_form_tag %>

40 Responses to “FCKEditor Plugin for Rails”

  1. photusEnigma Says:
    Nice! I was starting to look into creating something like this as I didn't expect an integration like this to be available yet (I'm a big FCKeditor fan and have used it in PHP & .NET, but not in any Rails projects yet), and am thrilled to find out it's already done and available for public use! Won't be able to get to playing with it today, but can't wait to see how it works in the project I'm currently working on!
  2. Mizan Says:
    Nice job... salute.. Thanks Mizanur Rahman
  3. Jerry Says:
    When i run rake fckeditor:install It show:Don't know how to build task 'fckeditor:install' I don't know why
  4. Scott Rutherford Says:
    Hi Jerry, You need to run the task from the root of your rails app, is that where you were? Cheers Scott.
  5. n Says:
    hmm, everything works but the file browser: when i click on image and then on file browser, it opens a new window but i get an xml request error and it shows neither file nor does it let me upload file or create a folder; snooped around but can't find anything. any ideas anyone?
  6. n Says:
    ah i figured it out ... just needed to tweak the settings file a bit; also there is a nice troubleshooting page here: http://wiki.fckeditor.net/Troubleshooting
  7. Scott Rutherford Says:
    @n great glad you got it working. thanks for the link. Scott.
  8. DAvid Says:
    Hi, it works fine in IE , but ? I can't get it to work in firefox... The text area doesn't appear and I get this javascript error : "this.DOMDocument has no properties" ... Any idea on how to resolve this issue?
  9. Scott Rutherford Says:
    @David, I'm not sure why you are getting that. It works fine for me in Firefox. Email me with more details if you don't make any progress. Cheers Scott.
  10. Dan Collis-Puro Says:
    What would be the most elegant way of throwing a before_filter in front of the fckeditor controller? I REALLY don't like the idea of leaving a controller with filesystem read/write privileges out in the open.
  11. Scott Rutherford Says:
    Hi Dan, what is it you want to do with the before_filter?
  12. acw1668 Says:
    Hi Scott, I have the same problem mentioned by David: the editing area is not shown in Firefox (both 1.5.0.x and 2.0), only the toolbars are shown. Error "this.DOMDocument has no properties" in fckeditorcode_gecko.js line 43 is shown in JavaScript Console. I'm using the lastest fckeditor-plugin version 0.4.0. Is the problem identified and solved?
  13. Scott Rutherford Says:
    Hi acw1668, I had another person contact me about this too. I have yet to see the issue but I will have to try and reproduce it and come up with a solution. I develop using FF2 so I know it works for me in that. Could you email me a stripped down version of the app so I could have a look? (scott [AT] caronsoftware.com) Cheers Scott
  14. Chris Says:
    Hi Scott...I bit off more than I could chew. I am new to Ruby on Rails and have been building a very basic CMS for my pops as my first "learning" project. So I thought, wouldn't it be nice if I integrated FCKeditor ...and followed all of the steps above, and now when I go to the page I dropped the "Using with HTML" code from above I get the error: undefined method `fckeditor_div_id' The page URL is: http://www.ojealo.net/lapostita/subpage/rates. I plan to integrate it here eventually: http://www.ojealo.net/lapostita/admin (work in process) If you could give me some direction here I would really appreciate it. Thanks, Chris
  15. James Penny Says:
    In firefox, when calling the fckeditor_textarea try putting in a :height and :width After I put these values in the textarea box appeared
  16. Dan Collis-Puro Says:
    bq. Scott Rutherford Wed, 29 Nov 2006 11:43:35 GMT Hi Dan, what is it you want to do with the before_filter? Whoa. Sorry for the slow reply to your reply. . . Time slips away, doesn't it. I simply want to authenticate/authorize users via methods I've already got in my ApplicationController. Wide open read/write privileges via the fckeditor controller are scary, and I want to lock that down.
  17. Scott Rutherford Says:
    @Chris, you need to include this in your header: <%= javascript_include_tag :fckeditor %> @James, thanks for posting that up. @Dan, if you add a before_filter in application.rb as so: before_filter :require_login, :only => :command that should do it. Cheers Scott
  18. Caspar Says:
    I had the firefox issue aswell. I resolved it by specifying a toolbarset and width and height, width and height alone didn't work for me. <%= fckeditor_textarea( :home_page_text, :text, :toolbarSet => 'Simple', :width => '800', :height => '500') %>
  19. tony.chestnut@gmail.com Says:
    I'm getting the XML request error: Internal Server Error (500) error and have no clue what could be causing it...railsfck.js was created with the necessary paths...the perms are correct for the uploaded folder....I looked at that page provided by an earlier comment...no help for rails apps....has anyone encountered this before...and how was it resolved?
  20. Kim Says:
    How do I install this plugin - the download here link at the top of the page goes to an empty page. I am using radrails and FCKeditor is not on the list of plugins. Please help.
  21. Kim Says:
    Sorry for the multiple posts before - I got it installed (but your link to rubyforg is broken) I have the FCKEditor_plugin files in my vendor/plugins folder. Now I cannot connect to my app - I get an Unable to connect Error - yes my server is started and the app works just find if I uninstall the plugin or move it to the vendor folder (have not even got to testing if the plugin works) Any suggestions?
  22. SpoBo Says:
    hey, excellent plugin. It made my pain partially go away. But I have a small problem with AJAX. I have a form_remote with FCK in it. I have placed the before filter so it gets parsed. The values show up in my controller, but I actually update the page dynamically(inline in the controller, I tried an .rjs as well) in the action but after doing the before filter it refused to do this properly. It just outputted the JavaScript to my browser. Is there a way to get this back to normal?
  23. Mike Johnson Says:
    Hey Scott, it appears your download link to RubyForge is broken. I went to the site and manually found this link (http://rubyforge.org/frs/download.php/15296/fckeditor_plugin-0.4.0.tgz)
  24. Karel Minarik Says:
    Hi Caspar, thanks for the tip, I was quite stuck in the "DOM element has no properties" in Firefox as well, and specifying the toolbar style has solved that issue. Karel
  25. Shai Shefer Says:
    Doesn't work with Safari? (or is it just me?)
  26. Nishant Sinha Says:
    Hi, its very nice,but sometimes I want to disable it in my application. Before using this I use ':disabled=>true' in my text area. I also try this in <%= fckeditor_textarea( "comment", "comment", :ajax => true, :disabled=>true) %> ,but it doesn't work. So,please help me how to disable text area of FCK Editor.
  27. Kuy Says:
    shai: FCKeditor itself doesn't support Safari yet. More info here: http://www.fckeditor.net/safari
  28. Reid Says:
    Has anyone built a wiki or CMS in Ruby On Rails that uses this plugin?
  29. Nii Amon Says:
    Hi all I just installed the plugin and I'm getting a rather strange error: can't dup Symbol. This happens when i use the javascript_include_tag in the Readme that came with the plugin. Can anyone please give me an explanation as to why this is happening and maybe how to go about fixing it. Thanks alot.
  30. Routing problem with FckEditor in rails Says:
    no route found to match "/javascript/editor/fckeditor.html" with {:method=>:get} when i try to used this solution it give me this error.
  31. Scott Says:
    Hi, I haven't seen that routing error. But I will have a look. Can you give me any more information? @Nii, sorry I didn't answer been very busy. I suspect you have included some javascript twice (probably :defaults). Cheers Scott.
  32. Peter Says:
    Thank you!
  33. kenrome@163.com Says:
    When i run rake fckeditor:install It show:Don’t know how to build task ‘fckeditor:install’ I don’t know why please help me
  34. Jean-Baptiste Says:
    Thanks for this plugin ! It helps alot... But I'm having a little problem with uploads : I can create folders fine, but when I try uploading a file, any file, I'll get a "Error on file upload. Error number: 403" popup... Any idea on what I'm doing wrong ?
  35. Jean-Baptiste Says:
    Ok, I finally found out what wasn't working. First, I was only trying with very small files. As soon as I began uploading bigger files, it worked. I discovered that with John Miller's comment here : http://blog.caronsoftware.com/articles/2007/04/10/fckeditor-0-4-1-available. Small edit, and it now works nice ! So, thanks for the plugin :)
  36. renuka Says:
    hi, i want to store images in uploads/users/user_id user_id is dynamic so can anyone say me how can i change path for that? please help me on this. give me reply as soon as possible thanks in advance
  37. warren Says:
    Any suggestions on how to get this to work in rails 2.0? Thanks,
  38. Konstantin Tikhonov Says:
    Hi, thanks for the plugin! I'm trying to write something like this: % fields_for "article[incuts][]", edit_incut do |form| -%> V<%= form.text_field :content, :size => 30 %> <% end -%> And I want to use fckeditor instead of text_field, but I can't just write form.fckeditor_textarea :content. How can I use fckeditor plugin in complex forms like http://railscasts.com/episodes/73 ?
  39. John Says:
    I have recently upgraded an application to Rails 2.0.2. The fckeditor itself works, however the image file manager does not. It looks like the connector is not being found by the rails router. I get the following error message in the log: Processing ApplicationController#index (for 127.0.0.1 at 2008-05-06 13:56:48) [GET] Session ID: 80ebd6bcf483bad22183bb3b01a9bd10 Parameters: {"CurrentFolder"=>"/", "Command"=>"GetFoldersAndFiles", "uuid"=>"1210096608457", "Type"=>"Image"} ActionController::RoutingError (No route matches "/fckeditor/command" with {:method=>:get}): Has anyone else seen this problem? Any hints about how to fix it, much appreciated in advance. -- John
  40. Scott Says:
    Hi John, I copied this over to the most recent "post":http://blog.caronsoftware.com/2008/2/6/fckeditor-plugin-0-4-3-released. As that I hope is where most people land, although it may not be. I'll have a look if I can replicate this. Scott

Sorry, comments are closed for this article.

This blog used the Shay theme as a base and is powered by Mephisto