Emili Parreño

Integrar FCKEditor y Ruby on Rails

08 Oct 2006 |

Para integrar el editor FCKEditor, he seguido los pasos que se explican en esta página. Primero tenemos que descargar el editor de la página oficial y copiar los siguientes ficheros en la carpeta 'public/javascripts' de nuestra aplicación.

/editor/
fckconfig.js
fckeditor.js
fckstyles.xml
fcktemplates.xml

Ahora editamos el fichero 'public/javascripts/fckeditor.js' y modificamos la línea:

Editamos el fichero 'app/helpers/application_helper.rb' y añadimos:

module ApplicationHelper
  def fckeditor_text_field(object, method, options = {})
    text_area(object, method, options ) +     javascript_tag( "var oFCKeditor = new FCKeditor('" + object + "_" + method + "');oFCKeditor.ReplaceTextarea()" )
  end
end

También añadimos en el del 'layout' que estamos utilizando, la siguiente lí­nea:

<%= javascript_include_tag "fckeditor" %>

Y por último editamos los ficheros '_form.rhtml' donde queremos insertar el FCKeditor y cambiamos el text_area por:

<%= fckeditor_text_field 'controlador', 'descipcion'  %>