I'm extremely new, and going through the basic ruby rails tutorial except tweaking it just to add some extra fields and renaming what it calls articles at contacts.
Problem is, everything is fine, except all my data is being added in as NIL. Here is my controller:
class ContactsController < ApplicationController
def index
@contacts = Contact.all
end
def show
@contacts = Contact.find(params[:id])
end
def new
end
def create
@contacts = Contact.new(contact_params)
@contacts.save
redirect_to @contacts
end
end
private
def contact_params
params.require(:contacts).permit(:first_name, :last_name, :phone_number, :notes)
end
my migrate file:
class CreateContacts < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.string :first_name
t.text :last_name
t.text :phone_number
t.text :notes
t.timestamps null: false
end
end
end
And I'm looking in my terminal and I see this:
Started POST "/contacts" for 127.0.0.1 at 2015-07-16 14:38:54 -0700
Processing by ContactsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"5l/werImOvbiPAq4rGB6oj8TILHKVVy96GGgRntzP2UwZxj6cSmIDsHzs RQZXbqHJATp60QMuRg7HWlLY5hf/w==", "contacts"=>{"First_name"=>"Hello", "Last_name"=>"AAGIN", "Phone_Number"=>"1231313", "Notes"=>"smsda"}, "commit"=>"Save Contacts"}
Unpermitted parameters: First_name, Last_name, Phone_Number, Notes
I think they're might be something about the 'unpermitted parameters' part, because there seems to be a difference in caps there.
If you see anything wrong, please let me know! Thank you. edit = here's my view:
<h1>New Contact</h1>
<%= form_for :contacts, url: contacts_path do |f| %>
<p>
<%= f.label :First_name %><br>
<%= f.text_field :First_name %>
</p>
<p>
<%= f.label :Last_name %><br>
<%= f.text_field :Last_name %>
</p>
<p>
<%= f.label :Phone_Number %><br>
<%= f.text_field :Phone_Number %>
</p>
<p>
<%= f.label :Notes %><br>
<%= f.text_area :Notes %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
<%= link_to 'Back', contacts_path %>