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.
ally on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
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?
michael on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
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.
ally on FCKeditor on Rails on Aug 20, 2008 at 09:24 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.
greg on FCKeditor on Rails on Aug 20, 2008 at 09:24 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?
Web-Dev » Blog Archive » FCKeditor on Rails on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
[...] 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. [...]
markus on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
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!
FCKEditor Plugin for Rails on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
[...] FCKEditor On Rails [...]
spiralstarez on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
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?
michael on FCKeditor on Rails on Aug 20, 2008 at 09:24 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
megl on FCKeditor on Rails on Aug 20, 2008 at 09:24 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
michael on FCKeditor on Rails on Aug 20, 2008 at 09:24 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.
megl on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
Thanks Michael. I added:
config.plugins = [“engines”, ”*”]
in environment.rb, but I still only get:
undefined method `fckeditor’
michael on FCKeditor on Rails on Aug 20, 2008 at 09:24 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?
megl on FCKeditor on Rails on Aug 20, 2008 at 09:24 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
michael on FCKeditor on Rails on Aug 20, 2008 at 09:24 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.
megl on FCKeditor on Rails on Aug 20, 2008 at 09:24 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!
asdfasdf on FCKeditor on Rails on Aug 20, 2008 at 09:24 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?
choongii on FCKeditor on Rails on Aug 20, 2008 at 09:24 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
choongii on FCKeditor on Rails on Aug 20, 2008 at 09:24 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.
choongii on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
Blargh, comment lenght limit >
choongii on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
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’).
dianna on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
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.
michael on FCKeditor on Rails on Aug 20, 2008 at 09:24 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.
Madan on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
When I installed the latest engines plugin I got the following error. “ActionView::TemplateError: can’t convert Hash into String”
It is thrown at the place where I have used
I am using Rails 2.1 currently. Can anyone please suggest how to get out of this problem?
Thanks :)
michael on FCKeditor on Rails on Aug 20, 2008 at 09:24 PM
@Madan – I installed the plugin in a fresh Rails 2.1.0 app and wasn’t able to reproduce your error.
Can you give me some of the stack trace around this error?
I did see that the quick upload is broken with the current FCKeditor though. I’ll need to look into that.
beda on FCKeditor on Rails on Feb 11, 2009 at 04:50 PM
Hi Madan I had teh same problem using this statement <%= javascript_include_tag :fckeditor %>
Try the following <%= javascript_include_tag “fckeditor” %>
Means using a string insteqad of a symbol
In my case it works
Reena on FCKeditor on Rails on Apr 13, 2009 at 04:17 AM
Hi,
Thank You