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:
- Integrate FCKEditor with your Ruby on Rails application By Joshua M Charles
- Implementation details for FCKEditor integration with Ruby on Rails
- 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
- Download and extract the tar in your plugins directory
- Run ‘rake fckeditor:install’ from the root of your rails application
- Add <%= javascript_include_tag “fckeditor/fckeditor” %> to the layout / head of the page you wish to use the editor on.
- 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 %>
November 25th, 2007 at 11:18 PM 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!
November 25th, 2007 at 11:18 PM Nice job... salute.. Thanks Mizanur Rahman
November 25th, 2007 at 11:18 PM When i run rake fckeditor:install It show:Don't know how to build task 'fckeditor:install' I don't know why
November 25th, 2007 at 11:18 PM Hi Jerry, You need to run the task from the root of your rails app, is that where you were? Cheers Scott.
November 25th, 2007 at 11:18 PM 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?
November 25th, 2007 at 11:18 PM 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
November 25th, 2007 at 11:18 PM @n great glad you got it working. thanks for the link. Scott.
November 25th, 2007 at 11:18 PM 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?
November 25th, 2007 at 11:18 PM @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.
November 25th, 2007 at 11:18 PM 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.
November 25th, 2007 at 11:18 PM Hi Dan, what is it you want to do with the before_filter?
November 25th, 2007 at 11:18 PM 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?
November 25th, 2007 at 11:18 PM 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
November 25th, 2007 at 11:18 PM 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
November 25th, 2007 at 11:18 PM In firefox, when calling the fckeditor_textarea try putting in a :height and :width After I put these values in the textarea box appeared
November 25th, 2007 at 11:18 PM 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.
November 25th, 2007 at 11:18 PM @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
November 25th, 2007 at 11:18 PM 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') %>
November 25th, 2007 at 11:18 PM 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?
November 25th, 2007 at 11:18 PM 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.
November 25th, 2007 at 11:18 PM 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?
November 25th, 2007 at 11:18 PM 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?
November 25th, 2007 at 11:18 PM 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)
November 25th, 2007 at 11:18 PM 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
November 25th, 2007 at 11:18 PM Doesn't work with Safari? (or is it just me?)
November 25th, 2007 at 11:18 PM 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.
November 25th, 2007 at 11:18 PM shai: FCKeditor itself doesn't support Safari yet. More info here: http://www.fckeditor.net/safari
November 25th, 2007 at 11:18 PM Has anyone built a wiki or CMS in Ruby On Rails that uses this plugin?
November 25th, 2007 at 11:18 PM 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.
November 25th, 2007 at 11:18 PM no route found to match "/javascript/editor/fckeditor.html" with {:method=>:get} when i try to used this solution it give me this error.
November 25th, 2007 at 11:18 PM 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.
November 25th, 2007 at 11:18 PM Thank you!
November 25th, 2007 at 11:18 PM 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
November 25th, 2007 at 11:18 PM 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 ?
November 25th, 2007 at 11:18 PM 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 :)
November 25th, 2007 at 11:18 PM 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
January 14th, 2008 at 05:15 PM Any suggestions on how to get this to work in rails 2.0? Thanks,
January 15th, 2008 at 02:50 AM 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 ?
May 6th, 2008 at 07:06 PM 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
May 8th, 2008 at 09:42 AM 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