FCKeditor on Rails
[UPDATE 2007-01-09]
So I’ve been writing Ruby/Rails to pay the bills for about 9 months now and this poor project has been suffering much longer than that. I had some time, wanted to clean this up and needed something that wasn’t work to code on to clear the head. So, if you are using Rails 1.2 you can now install this as a plugin in conjunction with Rails Engines or AppablePlugins.
You can get more info on the trac.
[/UPDATE]
I’ve been reading all this great stuff about Ruby on Rails so I told my boss that we should look into it, then I expensed a copy of Agile web Development with Rails and gave it a read. It looked promising.
I read a post on the Rails blog the other day about integrating FCKeditor with Rails and thought that would be a nice addition, unfortunately the method mentioned was little more than how to drop tags in a page to get FCKeditor to go. There wasn’t any real Rails to it.
I decided that would make a somewhat interesting project to start playing with Rails as it needs to interact with the file system a little. So I spent the past day-and-a-halfish building FCKeditor on Rails, it’s a little rough around the edges and I still want to integrate the mcpuk File Browser becasue it has so much more functionality than the default.
The end result is a Rails helper/controller that lets you add an FCKeditor instance just like you would expect in Rails:
fckeditor(:object, :param, {:width => '600px', :height => '500px'})
not to shabby. Now we will see how long it takes me to get around to adding mcpuk support.
The source can also be found in the FCKeditor trac project.
23 Responses to 'FCKeditor on Rails'
Leave a Reply
You must be logged in to post a comment.
on February 6th, 2006 at 8:14 am
This sounds really interesting. I too read the original article and decided it had been written too complicated.
Did you manage to get the filebrowser working successfully? Changing a couple of htaccess rules or something.
I am in the process of writing an app in rails which I plan to integrate fckeditor with. Is the code you have written releasable?
on February 6th, 2006 at 8:46 am
I don’t recall having to change anything to get the browser working. I’ll look into it this evening and update this with what I find.
OK, I didn’t make any changes to the .htaccess, all I can think of if you are having issues is the permissions of UserFiles and its children.
If you can give me some insight intot he kind of errors you are seeing, maybe I can provide more help.
on February 7th, 2006 at 2:53 pm
ah no this was a problem with the original integration method. just saw the actual code you have written will have a play. sorry for misunderstanding.
on May 2nd, 2006 at 3:07 pm
very nice and works good. Thanks!
How would one go about assigning the fcdeditor field a name like ‘copy’ so it could integrate with my current scaffolded _form view?
on June 1st, 2006 at 6:44 am
[…] All was well, but I could not get the file upload interface to work under Rails. So I did some searching and came across this project. Michael Moen had got it all to work ver nicely. […]
on June 29th, 2006 at 6:23 am
Hi,
first of all I have to thank you for this project. Thanks!
But I’ve noticed that the file upload do not work under windows. You have to replace “w” with “wb” in the second argument to File.open in file_upload (fckeditor_controller.rb).
I have made some other modifications to the code too, but mostly refactoring and clean up. Please get back to me if you want a copy of it.
Cheers!
on August 7th, 2006 at 12:01 pm
[…] FCKEditor On Rails […]
on October 25th, 2006 at 10:54 am
Hmmm, I found your code and I’ve been trying to implement it into a CMS I’m building. Everything seems to work okay at first, but something weird is happening with the encoding maybe? I tried it in my app first, and then the standalone version you have.
I’m running windows XP Pro, and when I try to upload a file it uploads to the proper directory, but when I try to view it or place it with the FCK it shows broken. If I try to open the uploaded image in Photoshop, it tells me the jpg is not properly encoded… Ideas?
on October 25th, 2006 at 9:15 pm
spiralstarez- Unfortunately I haven’t done any testing in Windows, there is a post 2 up form yours that mentions issues with the file mode on Windows, but I know that change is in.
But, now that I think of it if you grabbed the old tarballs, they are probably still broken.
If you have a subversion client you can check out the trunk and it should be good, if not let me know and I can probably get the tarball replaced tomorrow, Sorry about that.
svn co http://svn.underpantsgnome.com/fckeditor_on_rails/trunk fckeditor_on_rails
on March 8th, 2007 at 5:01 pm
Following your description on:
http://trac.underpantsgnome.com/fckeditor_on_rails
i do this:
ruby script/plugin install http://svn.rails-engines.org/plugins/engines
./script/plugin install http://svn.underpantsgnome.com/fckeditor_on_rails
what additional steps do I have to take to make it work? I get a server error, when I try to Engines.start :fckeditor_on_rails
Thanks in advance
on March 8th, 2007 at 5:07 pm
megl: You shouldn’t need to start the engine, if you add the plugin section to your config.
I put up a new page today http://trac.underpantsgnome.com/fckeditor_on_rails/wiki/RailsEngines that gives a little more detail.
Let me know if that helps.
on March 8th, 2007 at 5:21 pm
Thanks Michael. I added:
config.plugins = [”engines”, “*”]
in environment.rb, but I still only get:
undefined method `fckeditor’
on March 8th, 2007 at 5:26 pm
megl: can you grab http://underpantsgnome.com/dropbox/fckeditor.zip and see if it works? It’s a bare bones rails app.
Are you using Rails 1.2?
on March 8th, 2007 at 6:49 pm
I’m on 1.1.6, but I’ve frozen to 6039, which is 1.2. I have to stay at 1.1.6 because my host (Textdrive) is still 1.1.6 and I have really bad experiences with upgrading sooner than the host.
I tried to make a clean rails project, freeze to 6039, install engines and fckeditor_on_rails and I still getthe ‘undefined method’ error.
I’ve uploaded the project here: http://www.bechbox.dk/rails/fckeditor.zip
on March 8th, 2007 at 10:05 pm
megl: That’s odd. I downloaded that file and it runs fine. Something funky is going on in your environment.
What do the following print out?
./script/runner ‘puts Rails::VERSION::STRING’
RAILS_ENV=production ./script/runner ‘puts Rails::VERSION::STRING’
Sorry I don’t really know anything about the TextDrive environment.
on March 11th, 2007 at 2:46 pm
Hi again
./script/runner ‘puts Rails::VERSION::STRING’ prints out:
1.2.0
Very odd indeed, that the projects runs fine on your machine!
on March 17th, 2007 at 5:17 pm
i’m also having no luck here:
undefined method `fckeditor’
rails 1.2.2 on both freebsd/lighttpd and osx/webrick
also tried Michael and megl’s test projects and got the same result.
megl were you able to get this figured out?
on April 4th, 2007 at 2:33 pm
Megl, asdfasdf and anyone else who is getting the ‘undefined method’ error: you need to explicitly tell your controller to make use of the fckeditor helper. At least, that’s what fixed it for me. Example file app/controllers/bla_controller.rb:
[code]
class BlaController
on April 4th, 2007 at 2:40 pm
Addition to previous comment: I’m not into rails internals, but from reading http://wiki.rubyonrails.org/rails/pages/HowtoWorkWithHelpers it appears that each view’s helper is automatically loaded if it exists. That would explain why the demo at http://localhost:3000/fckeditor works; the controller is fckeditor_controller.rb so its helper, fckeditor_helper.rb is loaded automatically. So if you create a controller called ‘Bla’, you have to explicitly specify that you want to load the fckeditor helper. At least, that’s what I think it is.
on April 4th, 2007 at 2:51 pm
Blargh, comment lenght limit >
on April 5th, 2007 at 6:06 am
When developing with webrick/mongrel as your webserver and apache/lighty+fcgi(d) as your production server, the file browser may give errors because the working directory differs, so the sanitize_directory method returns false all the time. A quick and dirty hack is to add this as the final line of the ‘def get_options’ block: @options[:dir] = File.join(’.', @options[:url]) if Dir.pwd.ends_with?(’/public’).
on July 23rd, 2007 at 10:48 am
Has anyone that was having problems figured this out? I’m still getting either “no such file to load — fckeditor_on_rails” or “undefined method `fckeditor’”. I added the stuff to the environment for engines, included engines and fckeditor_on_rails, and added the helper_method :fckeditor. This is driving me crazy… this seems like the best way to implement the plugin but I can’t figure it out to save my life. BTW, total newbie, so I’m also totally confused about everything.
on August 19th, 2007 at 5:25 pm
Hey folks, really sorry about all the delays in getting this problem resolved.
I believe that the current version in svn is working, there seems to have been an issue with the load order in the latest version of Rails causing the application helper monkey patches to get lost.