vendredi 27 novembre 2015

"Simple Form" data not inserting into database

I have a form that looks like this

<%= simple_form_for @contact_form, url: contact_form_index_path, method: :post do |f| %>
    <%= f.input :first_name, placeholder: 'Jane' %>
    <%= f.input :last_name, placeholder: 'Doe' %>
    <%= f.input :email, placeholder: 'example@email.com' %>
    <%= f.input :address, placeholder: '123 Main Street' %>
    <%= f.input :city, placeholder: 'Pleasantville' %>
    <%= f.input :state, placeholder: 'NJ' %>
    <%= f.input :zip_code, placeholder: '12345' %>
    <%= f.input :phone, placeholder: '(123) 456-7890' %>
    <%= f.button :submit %>
<% end %>

My db schema looks like this;

create_table "contact_forms", force: :cascade do |t|
    t.string   "first_name"
    t.string   "last_name"
    t.string   "email"
    t.string   "address"
    t.string   "city"
    t.string   "zip_code"
    t.string   "state"
    t.integer  "phone"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

When I test out the form and try to post the entered data into my database, I do not receive an error, but the data is not populated into the table.

Do you know what could be causing this? Below are the logs, if it helps.

 Parameters: {"utf8"=>"✓", "authenticity_token"=>"IniAUnB4O51+1KrNy5Ip/nVPqmEZaXopoFozaBu98bkvg0MP5GxbEkzKKltY/QuVomxE2hnDT7cIloy99u0Nsw==", "contact_form"=>{"first_name"=>"Jack", "last_name"=>"Burum", "email"=>"", "address"=>"", "city"=>"", "state"=>"", "zip_code"=>"", "phone"=>""}, "commit"=>"Create Contact form"}
   (0.1ms)  begin transaction
  SQL (0.3ms)  INSERT INTO "contact_forms" ("created_at", "updated_at") VALUES (?, ?)  [["created_at", "2015-11-27 18:37:45.421056"], ["updated_at", "2015-11-27 18:37:45.421056"]]
   (7.3ms)  commit transaction
Redirected to http://localhost:3000/pages
Completed 302 Found in 11ms (ActiveRecord: 7.7ms)

Aucun commentaire:

Enregistrer un commentaire