Form is not saving data upon submission

When I click the submit button, the form automatically refreshes the
page. The console doesn't show any errors related to strong parameters
as stated below. I will post the controller, _form view and model
information

Started GET
"/articles/new?utf8=%E2%9C%93&authenticity_token=GP%2Fm4GX2Z2CUjuFt5QJOEEcIcEtKzsd9nPGQ6OfmMQn2yiUHqwoGPvzQiu2hSiPK0V8%2Br1r%2F0TfC5zZM26Y2VA%3D%3D&article%%5Bcategory_id%5D=1&commit=Create+Article"
for 127.0.0.1 at 2016-03-08 18:30:00 -0500
Processing by ArticlesController#new as HTML
  Parameters: {"utf8"=>"✓",
"authenticity_token"=>"GP/m4GX2Z2CUjuFt5QJOEEcIcEtKzsd9nPGQ6OfmMQn2yiUHqwoGPvzQiu2hSiPK0V8+r1r/0TfC5zZM26Y2VA==",
"article"=>{"title"=>"Awesome Title!",
"subtitle"=>"I cannot wait to get back home",
"prev_img"=>"movies.jpg", "body"=>"<p>Wow. This is
absolutely brilliant and beautiful.</p>\r\n", "category_id"=>"1"},
"commit"=>"Create Article"}
  Category Load (0.5ms) SELECT "categories".* FROM "categories"
  Rendered articles/_form.html.erb (19.5ms)
  Rendered articles/new.html.erb within layouts/application (22.5ms)
  User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" =
? ORDER BY "users"."id" ASC LIMIT 1 [["id", 5]]
  Rendered navigation/_navbar.html.erb (9.5ms)
Completed 200 OK in 2011ms (Views: 2009.3ms | ActiveRecord: 0.5ms)

<div class="container">
  <form class="article-form-template">
    <%= simple_form_for(@article, html: {class: 'form-horizontal',
:multipart => true}) do |f| %>
        <% if @article.errors.any? %>
            <div id="error_explanation">
            <- omitted ->
        <% end %>

        <fieldset class="form-group">
          <%= f.input :title, class: 'form-control', placeholder:
"Headline" %>
        </fieldset>

        <fieldset class="form-group">
          <%= f.input :subtitle, class: 'form-control', placeholder:
'Description' %>
        </fieldset>

        <fieldset>
          <i class="fa fa-picture-o"></i>
          <img id="img_prev" width=370 height=180 src="#" alt=""
class="img-thumbnail hidden"/> <br/>
          <%= f.label :prev_img, 'Select a preview image for your
article' %>
          <%= f.file_field :prev_img, class: 'form-control-file', id:
'img-upload' %>
        </fieldset>

        <div class="form-inputs">
          <%= f.cktext_area :body %>
        </div>
        <div class="field">
          <%= f.label :category_id, 'Select a category' %>
          <%= f.collection_select :category_id, Category.all, :id, :name
%>
        </div>
        <div class="form-actions">
          <%= f.submit 'Submit Info', class: 'btn btn-primary' %>
        </div>
    <% end %>
  </form>
  <script>
  </script>
</div>

class ArticlesController < ApplicationController
  before_action :set_article, only: [:show, :edit, :update, :destroy]

  def index
   @Articles = Article.all
  end

  def show
  end

  def new
    @article = Article.new
  end

  def edit
  end

  def create
    @user = current_user
    @article = @user.articles.build(article_params)
    @category = Category.find(params[:category_id])
    @article.category = @category
    respond_to do |format|
      if @article.save
        format.html { redirect_to @article, notice: 'Article was
successfully created.' }
        format.json { render :show, status: :created, location: @article
}
        format.js
      else
        format.html { render :new }
        format.json { render json: @article.errors, status:
:unprocessable_entity }
      end
    end
  end

  def update
    respond_to do |format|
      if @article.update(article_params)
        format.html { redirect_to @article, notice: 'Article was
successfully updated.' }
        format.json { render :show, status: :ok, location: @article }
      else
        format.html { render :edit }
        format.json { render json: @article.errors, status:
:unprocessable_entity }
      end
    end
  end

  def destroy
    if @article.user == current_user
      @article.destroy
      redirect_to articles_path
      flash[:success] = "Article has been removed"
    else
      redirect_to :back
      flash[:danger] = "Unable to remove Article"
    end
    respond_to do |format|
      format.html
      format.json { head :no_content }
    end
  end

  private
  def set_article
    @article = Article.find(params[:id])
  end

  def article_params
    params.require(:article).permit(:title, :body, :subtitle, :prev_img,
:category_id, :description)
  end
end

class Article < ActiveRecord::Base
  belongs_to :user
  belongs_to :category
  has_many :comments, as: :commentable, dependent: :destroy
  default_scope -> { order(created_at: :desc) }
  mount_uploader :prev_img, PrevImgUploader
  validates :prev_img, presence: true
  validates :body, presence: true
  validates :title, presence: true
  validates :subtitle, presence: true
end

class Category < ActiveRecord::Base
  has_many :articles
end

After attempting to create a record in the console. I get the output
below

   (0.5ms) begin transaction
  Article Exists (0.0ms) SELECT 1 AS one FROM "articles" WHERE
("articles"."id" != 12) AND "articles"."slug" = ? LIMIT 1 [["slug",
"wow-the-movie-was-great"]]
   (0.0ms) rollback transaction
false

I created 5 scoping methods inside of category.rb for targeting specific
categories. I don't know why the records are not saving. I wrote the
form properly and routes correctly.

resources :articles do
    member do
      get 'like', to: 'articles#like'
      get 'dislike', to: 'articles#unlike'
    end
  end

When I click the submit button, the form automatically refreshes the
page.

Started GET
"/articles/new?

utf8=%E2%9C%93&authenticity_token=GP%2Fm4GX2Z2CUjuFt5QJOEEcIcEtKzsd9nPGQ6OfmMQn2yiUHqwoGPvzQiu2hSiPK0V8%2Br1r%2F0TfC5zZM26Y2VA%3D%3D&article%%5Bcategory_id%5D=1&commit=Create+Article"

for 127.0.0.1 at 2016-03-08 18:30:00 -0500
Processing by ArticlesController#new as HTML

It should be pretty apparent that you're accessing the "#new"
method in your controller, NOT the "#create", which would be
done via POST.

<div class="container">
  <form class="article-form-template">
    <%= simple_form_for(@article, html: {class: 'form-horizontal',
:multipart => true}) do |f| %>

?! You're creating a form tag within a form tag - not valid HTML in
any way. And that outer form has no method or action attributes, so
not much is ever going to happen, as you see :slight_smile:

Hassan Schroeder wrote in post #1182051:

?! You're creating a form tag within a form tag - not valid HTML in
any way. And that outer form has no method or action attributes, so
not much is ever going to happen, as you see :slight_smile:

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Consulting Availability : Silicon Valley or remote

I fixed the form, I didn't realize that I was still using the
<form></form> approach that I needed for Stripe. Which doesn't pass the
form to the database, but transfers the information over the internet
back to stripe.

I have one problem though, the category_id is not being found when I
submit the form.

Thanks, I fixed the form. We can close this issue.