NoMethodError in Signups#new (undefined method `email' for #<Signup id: nil, created_at: nil, updated_at: nil>)


#1

I am getting an error:

undefined method 'email' for #<Signup id: nil, created_at: nil, updated_at: nil>

the line of code highlighted in the error message is:

<%= f.text_field :email %>

There is a previous thread with this issue ( https://discuss.codecademy.com/t/undefined-method-email-for-signup-id-nil-created-at-nil-updated-at-nil/23363 ) but I have implemented the fix suggested (ensuring that the data type for email in the migration file is string instead of text and ensuring that the form input type is text_field). This does not fix the problem. Can anyone shed light on this.

My View file (new.html.erb)

        <!-- Your code here -->
        <%= form_for(@signup) do |f| %>  
  <div class="field"> 
    <%= f.label :signup %> 
    <%= f.text_area :email %> 
  </div> 
  <div class="actions"> 
    <%= f.submit "Sign Up" %> 
  </div> 
<% end %>

My migration file

class CreateSignups < ActiveRecord::Migration
  def change
    create_table :signups do |t|
		t.string :email
      
      t.timestamps
    end
  end
end

My Signup controller

class SignupsController < ApplicationController
  
  def new
  	@signup = Signup.new
  end
  
  
end

#2

did you happen to add the email:? cause it's not in the stored migration file. try to run rake db:migrate