title: How to capture content typed in a rich text editor and save it in a Rails model? - Quill rich editor
body: <p>I'm new to this and I'm trying to create a rich text editor for my blog. I am using Quill as a rich text editor for my Ruby on Rails application. I have set it up, but I am now running into a problem of saving the content typed into the editor.</p>
  
  <p>Here is my form:</p>
  
  <pre><code>&lt;%= form_for @post do |f| %&gt;
    &lt;% if @post.errors.any? %&gt;
      &lt;h2&gt;&lt;%= pluralize(@post.errors.count, "error")%&gt; prevented this post from saving:&lt;/h2&gt;
      &lt;ul&gt;
        &lt;% @post.errors.full_messages.each do |msg| %&gt;
        &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
        &lt;% end %&gt;
      &lt;/ul&gt;
    &lt;% end %&gt;
  
  &lt;%= f.label :title %&gt;&lt;br&gt;
  &lt;%= f.text_field :title %&gt;
  
  &lt;%= f.label :content, "Write your article here" %&gt;&lt;br&gt;&lt;br /&gt;
  
  &lt;div class="editor"&gt;
    &lt;div id="toolbar"&gt;&lt;/div&gt;
    &lt;div id="editor"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;%= f.hidden_field :content, id: "form" %&gt;
  
  &lt;%= f.submit "Publish" %&gt;
  &lt;% end %&gt;
  
  &lt;script src="https://cdn.quilljs.com/1.2.2/quill.js"&gt;&lt;/script&gt;
  &lt;script&gt;    
    var toolbarOptions = [
      ['bold', 'italic', 'underline', 'strike'],
      ['blockquote'],
      [{'header': [1, 2, 3, 4, 5, 6, false]}],
      [{'align': []}],
      [{'list': 'ordered'}, {'list': 'bullet'}],
      [{'color': [] }, { 'background': [] }],
      ['link', 'image', 'video'],
    ]
  
    var quill = new Quill('#editor', {
      modules: {
        toolbar: toolbarOptions
      },
  
      theme: 'snow'
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is my Posts controller:</p>
  
  <pre><code>class PostsController &lt; ApplicationController
    before_action :find_post, only: [:show, :edit, :update, :destroy]
    before_action :authenticate_user!, except: [:index, :show]
    before_action :load_user,  only: [:show]
    before_action :create,  only: [:unapprove]
    load_and_authorize_resource
  
    def load_user
      if @post.user != nil
        @user = @post.user
      end
    end
  
    def index
      @posts = Post.approved.all.order("created_at desc").paginate(page: params[:page], per_page: 15)
    end
  
    def new
      if user_signed_in?
        @post = current_user.posts.build
      else
        @post = Post.new
      end
    end
  
    def create
      if user_signed_in?
        @post = current_user.posts.build(post_params)
      else
        @post = Post.new(post_params)
      end
  
      if @post.save &amp;&amp; @post.approved &amp;&amp; @post.after_approved
        redirect_to @post, notice: "Congrats! Your post was successfully published on The Teen Magazine!"
      elsif @post.save
        redirect_to @post, notice: "Changes were successfully saved!"
      else
        render 'new', notice: "Oh no! Your post was not able to be saved!"
      end
    end
  
    def show
      redirect_to root_path unless (@post.approved || (current_user &amp;&amp; (@post.user_id == current_user.id || current_user.admin?)))
      set_meta_tags title: @post.title,
                    description: @post.meta_description,
                    keywords: @post.keywords
    end
  
    def unapprove
      @post = Post.unscoped.update(params[:approve], :approved =&gt; false)
      render :action =&gt; :success if @post.save
    end
  
    def edit
    end
  
    def update
      if @post.update post_params
        redirect_to @post, notice: "Changes were successfully saved!"
      else
        render 'edit'
      end
    end
  
    def destroy
      @post.destroy
      redirect_to posts_path
    end
  
    private
  
    def post_params
      params.require(:post).permit(:title, :content, :image, :category, :category_id, :meta_title, :meta_description, :keywords, :user_id, :admin_id, :waiting_for_approval, :approved, :after_approved, :created_at, :slug)
    end
  
    def find_post
      @post = Post.friendly.find(params[:id])
    end
  end
  </code></pre>
  
  <p>I need to save the content from Quill to 'content' in Posts.</p>
  
  <p>Any help is much appreciated. Thank you.</p>