Showing posts with label WYSIWYG. Show all posts
Showing posts with label WYSIWYG. Show all posts

Wednesday, March 16, 2011

WYSIWYG editor for Rails3

If you are looking for a WYSIWYG editor for Rails3, then NicEdit is the one of the best editor.

NicEdit is a Lightweight and Inline Content Editor which is pretty easy to install and use with Rails application.
This can also be used with Rails3 latest version.

Steps to install:
  • Download nicEdit.js file from http://nicedit.com/index.php
  • Copy and paste the file in public/javascripts folder
  • Include js file in layout.
    <%= javascript_include_tag 'nicEdit' -%>
  • Paste following code above the form where you want to display Editor
<script type="text/javascript">
       bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
</script>
For ex- If you want to display the Editor in Users new form then paste the code above that form.
And thats it!
Any text area in that form will be displaying NicEditor with rows and columns which you mention
<%= f.text_area :news, :cols=>"100", :rows=>"15" %>