Rails 3 and Rich text editor

JavascriptRuby on-RailsRich Text-Editor

Javascript Problem Overview


I am building a Rails 3 app with blogging, commenting, and other functionality that require the users to input text.

My question is whether it is a better idea to use a Javascript rich text editor or not. What would be the pros and cons. If it is a recommended approach:

  1. Which editors are best?
  2. How do I use them in my Rails forms?

thanks in advance,

Steve

Javascript Solutions


Solution 1 - Javascript

Most rich text editors for the web use JavaScript. These are some popular ones you could consider

  1. jwysiwig
  2. markitup
  3. Redactor (This is great jQuery based wysiwyg editor that also has a Rails extension I've linked to below.)
  4. Bootstrap-wysihtml5 (If you're looking for a Twitter Bootstrap style editor)

Of course, you could also consider heavy-weight alternatives like TinyMCE or CKEditor, if your needs are such.

Ruby on Rails Solutions

If you need to able add images to your textarea through a Ruby on Rails library, such as Paperclip or Carrierwave, you may consider one of these

  1. rails-ckeditor
  2. Mercury (Railscast)
  3. rails_tiny_mce
  4. redactor-rails

The Problem with using a usual JavaScript Editor

Most javascript editors will prompt for a URL when you try to add an image to your textarea, so if you need to do so, you may have to upload the image elsewhere and provide the editor with the URL.

There is however one JavaScript editor I found, http://nicedit.com/, that does an AJAX upload to http://imageshack.us when you add an image. Of course, the images that are served will become totally dependent on imageshack which may or may not work for you. It really depends on your scenario.

Solution 2 - Javascript

I use CKEditor

I would advise you to install the rails_admin gem and follow the instructions in the README to set-up CKEditor

It's really easy to use, looks good and is regularly maintained

If you prefer not to use rails_admin gem, then you can use one of the many rails ckeditor gems

good luck

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSteve HarmanView Question on Stackoverflow
Solution 1 - JavascriptShreyasView Answer on Stackoverflow
Solution 2 - JavascriptstephenmurdochView Answer on Stackoverflow