use multiple instances of FCK Editor when editing a Rails collection
Scott Rutherford has kindly packaged up a Rails helper for the FCK Editor as a plugin. You can find it here.
I was stumped for a while as I wanted to use multiple instances of the editor in a form used to edit a collection of objects, but figured it out with a little help from Scott.
I was using the syntax:
<%= text_field("product[]", "name", :size => 60) %>
<%= fckeditor_textarea("product[]", 'description', ... %>
gave me the error:
(eval):1:in `[]': wrong number of arguments (0 for 1)
<textarea id='product_3893_description_editor'
name='product[3893][description]'>blank</textarea>
<%= fckeditor_textarea_multi( "product", "description",
@product.id, { ...}) %>
def fckeditor_textarea_multi(object, field, new_arg, options = {})
... [snip] ...
inputs = "<textarea id='#{id}' #{cols} #{rows}
name='#{object}[#{new_arg}][#{field}]'>
#{value}</textarea>\n"
... [snip] ...