Search code examples
ruby-on-railsrubygemsckeditor

Ckeditor ruby gem adds ">" at the end of the entries every time a user edits the textarea entry


Ckeditor ruby gem is adding a ">" at the end of my content entries every time a user edits the content. Here is a video of it happening: https://drive.google.com/file/d/16sus8LGxHBZLFs_ts5_SJJSwLfisJzom/view?usp=sharing

Here is my update_row controller code for the text_component model. The textarea input is being saved in the content column.
def update_row @text_component = TextComponent.find(params.fetch("id_to_modify"))

@text_component.tab_id = params.fetch("tab_id")
@text_component.content = params.fetch("content")

if @text_component.valid?
  @text_component.save

  redirect_to("/guides/"+params.fetch("guide_id"), :notice => "Text component updated successfully.")
else
  @guide = Guide.find(params.fetch("guide_id"))
  render("guide_templates/show.html.erb")
end
end

ANSWERED: here is the working form code in my edit_form view:

  <form action="/update_text_component/<%= @text_component.id %>"  method="post">
  <!--input for guide_id -->
  <div class="form-group">

    <input type="hidden" id="guide_id" name="guide_id" class="form-control" value="<%= params.fetch("guide_id") %>">
  </div>
    <!-- input for tab_id -->
  <div class="form-group">
    <input type="hidden" id="tab_id" name="tab_id" class="form-control" value="<%= params.fetch("tab_id") %>">
  </div>

  <div class="form-group">
    <label for="content">
      Content
    </label>

    <textarea id="content" name="content" class="ckeditor" rows="10"><%= raw @text_component.content %></textarea>
  </div>

  <button class="btn btn-block btn-outline-secondary">
    Update text component
  </button>
</form>

Solution

  •   <form action="/update_text_component/<%= @text_component.id %>"  method="post">
      <!--input for guide_id -->
      <div class="form-group">
    
        <input type="hidden" id="guide_id" name="guide_id" class="form-control" value="<%= params.fetch("guide_id") %>">
      </div>
        <!-- input for tab_id -->
      <div class="form-group">
        <input type="hidden" id="tab_id" name="tab_id" class="form-control" value="<%= params.fetch("tab_id") %>">
      </div>
    
      <div class="form-group">
        <label for="content">
          Content
        </label>
    
        <textarea id="content" name="content" class="ckeditor" rows="10"><%= raw @text_component.content %></textarea>
      </div>
    
      <button class="btn btn-block btn-outline-secondary">
        Update text component
      </button>
    </form>