app/helpers/application_helper.rb
# Inserts TinyMCE text editor that edits given property (text property).
# If :editable_header and :header_prop options are provided, the header will be editable too.
# Otherwise, :header option can be used to use constant header / title
Inserts TinyMCE text editor that edits given property (text property).
If :editable_header and :header_prop options are provided, the header will be editable too.
Otherwise, :header option can be used to use constant header / title
Inserts TinyMCE text editor that edits given property ( text property ) . If : editable_header and : header_prop options are provided the header will be editable too . Otherwise : header option can be used to use constant header / title
def text_editor (object, property, options={})
    update_url = options.delete(:update_url) || url_for(object)
    id = "text-editor-#{property}-#{object.class.to_s.underscore}-#{object.id}"
    text_prop_name = "#{object.class.to_s.underscore}[#{property}]"
    text_value = object.send(property)
    header_prop_name = options[:header_prop] ? "#{object.class.to_s.underscore}[#{options[:header_prop]}]" : "non-editable-header"
    header_value =  options[:header_prop] ? object.send(options[:header_prop]) : nil
    %{
      <div id="#{id}"></div>
      <script type="text/javascript">
        (function() {
          var props = {
            data: {
              "#{text_prop_name}": #{text_value.to_json},
              "#{header_prop_name}": #{(header_value ? header_value : options[:header]).to_json},
            },
            updateUrl: "#{update_url}",
            textPropName: "#{text_prop_name}",
            headerPropName: "#{header_prop_name}",
            editableHeader: #{options[:editable_header] || false}
          };
          TextEditor = React.createElement(modulejs.require('components/authoring/text_editor'), props);
          ReactDOM.render(TextEditor, $("##{id}")[0]);
        }());
      </script>
    }.html_safe
  end
def text_editor ( object , property , options = { } ) update_url = options . delete ( :update_url ) || url_for ( object ) id = "text-editor-#{property}-#{object.class.to_s.underscore}-#{object.id}" text_prop_name = "#{object.class.to_s.underscore}[#{property}]" text_value = object . send ( property ) header_prop_name = options [ :header_prop ] ? "#{object.class.to_s.underscore}[#{options[:header_prop]}]" : "non-editable-header" header_value = options [ :header_prop ] ? object . send ( options [ :header_prop ] ) : nil %{
      <div id="#{id}"></div>
      <script type="text/javascript">
        (function() {
          var props = {
            data: {
              "#{text_prop_name}": #{text_value.to_json},
              "#{header_prop_name}": #{(header_value ? header_value : options[:header]).to_json},
            },
            updateUrl: "#{update_url}",
            textPropName: "#{text_prop_name}",
            headerPropName: "#{header_prop_name}",
            editableHeader: #{options[:editable_header] || false}
          };
          TextEditor = React.createElement(modulejs.require('components/authoring/text_editor'), props);
          ReactDOM.render(TextEditor, $("##{id}")[0]);
        }());
      </script>
    } . html_safe end
Inserts TinyMCE text editor that edits given property (text property).
Inserts TinyMCE text editor that edits given property ( text property ) .
object
<not_specific>
property
<not_specific>
options
<not_specific>