title: Rails comments do not save
body: <p>Edit: Log from form submission:</p>
  
  <pre><code>Started POST "/posts/1/comments" for 141.161.133.10 at 2015-03-19 17:10:19 +0000
  Processing by CommentsController#create as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"9laIJxseq/x+7C3iJAdpvalFvMgN397lWC7c/6Ha/hEjKTE9A3e19liFlwGzZjePReFdh2F1fLj1itZzRjixgQ==", "comment"=&gt;{"body"=&gt;"Hi stackoverflow"}, "commit"=&gt;"Submit", "post_id"=&gt;"1"}
     (0.3ms)  begin transaction
    SQL (1.9ms)  INSERT INTO "comments" ("body", "created_at", "updated_at") VALUES (?, ?, ?)  [["body", "Hi stackoverflow"], ["created_at", "2015-03-19 17:10:19.808006"], ["updated_at", "2015-03-19 17:10:19.808006"]]
     (32.1ms)  commit transaction
  Redirected to https://blog-erikvdw.c9.io/posts.10
  Completed 302 Found in 48ms (ActiveRecord: 34.2ms)
  </code></pre>
  
  <p>And comment_params method:</p>
  
  <pre><code>def comment_params
    params.require(:comment).permit(:body)
  end
  </code></pre>
  
  <p>I've looked around quite a while in a <a href="https://github.com/mackenziechild/blog/find/master" rel="nofollow">github repo</a> and other SO questions similar to what I am doing, but haven't seen exactly what I'm doing wrong.  My problem is that comments are not being created when the comments form is submitted in Posts/Show.  I presume it to be an issue with an activerecord association:</p>
  
  <p>Posts/Show</p>
  
  <pre><code>&lt;% content_for(:title, @post.title ) %&gt;
  &lt;p id="notice"&gt;&lt;%= notice %&gt;&lt;/p&gt;
  
  &lt;h1&gt;Blog&lt;/h1&gt;
  &lt;br&gt;
  &lt;div&gt;
    &lt;%= image_tag @post.image.full.url %&gt;
  &lt;/div&gt;
  &lt;div class="panel panel-default"&gt;
    &lt;div class="panel-heading"&gt;
      &lt;h2&gt;&lt;em&gt;&lt;%= @post.title %&gt;&lt;/em&gt;&lt;/h2&gt;
    &lt;/div&gt;
    &lt;div class="panel-body"&gt;
      &lt;p&gt;&lt;%= @post.content %&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;%= link_to 'Edit', edit_post_path(@post) %&gt; |
  &lt;%= link_to 'Back', posts_path %&gt;
  
  &lt;% @post.comments.each do |comment| %&gt;
    &lt;%= comment.body %&gt;
  &lt;% end %&gt;
  
  &lt;%= form_for [@post, @post.comments.build] do |f| %&gt;
    &lt;%= f.text_area :body %&gt;
    &lt;%= f.submit "Submit" %&gt;
  &lt;% end %&gt;
  &lt;p&gt;Comments: &lt;%= @post.comments.count %&gt;&lt;/p&gt;
  </code></pre>
  
  <p>Posts Model</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
      has_many :comments, dependent: :destroy
      mount_uploader :image, PostUploader 
  
  end
  </code></pre>
  
  <p>Comments Model</p>
  
  <pre><code>class Comment &lt; ActiveRecord::Base
      belongs_to :user
      belongs_to :post
  end
  </code></pre>
  
  <p>Schema File</p>
  
  <pre><code>create_table "comments", force: :cascade do |t|
      t.string   "body"
      t.integer  "user_id"
      t.integer  "employee_id"
      t.datetime "created_at",  null: false
      t.datetime "updated_at",  null: false
      t.integer  "post_id"
    end
  
    add_index "comments", ["employee_id"], name: "index_comments_on_employee_id"
    add_index "comments", ["post_id"], name: "index_comments_on_post_id"
    add_index "comments", ["user_id"], name: "index_comments_on_user_id"
  
    create_table "posts", force: :cascade do |t|
      t.string   "title"
      t.text     "content"
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
      t.string   "image"
    end
  
    create_table "users", force: :cascade do |t|
      t.string   "first_name"
      t.string   "last_name"
      t.string   "username"
      t.datetime "created_at",                          null: false
      t.datetime "updated_at",                          null: false
      t.string   "email",                  default: "", null: false
      t.string   "encrypted_password",     default: "", null: false
      t.string   "reset_password_token"
      t.datetime "reset_password_sent_at"
      t.datetime "remember_created_at"
      t.integer  "sign_in_count",          default: 0,  null: false
      t.datetime "current_sign_in_at"
      t.datetime "last_sign_in_at"
      t.string   "current_sign_in_ip"
      t.string   "last_sign_in_ip"
    end
  
    add_index "users", ["email"], name: "index_users_on_email", unique: true
    add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
  </code></pre>
  
  <p>Comments_Controller New and Create Actions</p>
  
  <pre><code>def new
      @comment = Comment.new
    end
  
    # POST /comments
    # POST /comments.json
    def create
      @comment = Comment.new(comment_params)
  
      respond_to do |format|
        if @comment.save
          format.html { redirect_to posts_path(@comment), notice: 'Comment was successfully created.' }
          format.json { render :show, status: :created, location: @comment }
        else
          format.html { render :new }
          format.json { render json: @comment.errors, status: :unprocessable_entity }
        end
      end
    end
  </code></pre>