I'm rails noob. I have a problem with contact form.
I have an error: undefined method 'name' for nil:NilClass
<p>
<strong>Name:</strong>
<%= @contact_forms.name %>
</p>
My manager.html.erb is:
<div>
<p>
<strong>Name:</strong>
<%= @contact_forms.name %>
</p>
<p>
<strong>Text:</strong>
<%= @contact_forms.text %>
</p>
</div>
My contact_form_controller.rb is:
class ContactFormController < ApplicationController
def new
end
def create
@contact_forms = Contact_form.new(params[:contact_form])
@contact_forms.save
redirect_to root_path
end
def show
@contact_forms = Contact_form.all
end
end
My file with migrates:
class CreateContactForms < ActiveRecord::Migration
def change
create_table :contact_forms do |t|
t.string :name
t.string :phone
t.string :email
t.text :text
t.timestamps null: false
end
end
end
my static_pages_controller.rb is
class StaticPagesController < ApplicationController
def home
end
def manager
end
end
Thanks