title: Ruby rails undefined method 'name' @user
body: <p>I get the error when trying to display a sign up form:</p>
  
  <pre><code>undefined method `name' for `#&lt;User id: nil, created_at: nil,
  updated_at: nil, email: nil&gt;
  </code></pre>
  
  <blockquote>
    <p>Extracted source (around line #8):</p>
    
    <p>6 7 8 9 10 11</p>
    
        
  </blockquote>
  
  <p>In users/new.html.erb</p>
  
  <pre><code>&lt;div class="row"&gt;
    &lt;div class="col-md-6 col-md-offset-3"&gt;
      &lt;%= form_for(@user) do |f| %&gt;
        &lt;%= f.label :name %&gt;
        &lt;%= f.text_field :name %&gt;
  
        &lt;%= f.label :email %&gt;
        &lt;%= f.email_field :email %&gt;
  
        &lt;%= f.label :password %&gt;
        &lt;%= f.password_field :password %&gt;
  
        &lt;%= f.label :password_confirmation, "Confirmation" %&gt;
        &lt;%= f.password_field :password_confirmation %&gt;
  
        &lt;%= f.submit "Create my account", class: "btn btn-primary" %&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>If I comment out that one line, it works. I've defined the name field in my model:</p>
  
  <p>db/migrate/....create_users.rb</p>
  
  <pre><code>class CreateStructure &lt; ActiveRecord::Migration
    def change
      def up
          drop_table :users
          create_table :users do |t|
              t.integer :id
              t.string :name
              t.string :email
              t.string :password
          end
  
          create_table :model_forums do |t|
              t.integer :id
              t.string :name
          end
      end
    end
  end
  </code></pre>
  
  <p>But it doesn't create the fields I ask for, and only has the old fields like created_at and updated_at.</p>