Ruby on rails 铁路标250后出现的命名错误

Ruby on rails 铁路标250后出现的命名错误,ruby-on-rails,Ruby On Rails,我正在遵循“从头开始认证”railscast,但无法使其工作 控制器: class UsersController < ApplicationController def new @user = User.new end def create @user = User.new(params[:user]) if @user.save redirect_to products_path, not

我正在遵循“从头开始认证”railscast,但无法使其工作

控制器:

class UsersController < ApplicationController
    def new
        @user = User.new
    end

    def create
        @user = User.new(params[:user])
        if @user.save
            redirect_to products_path, notice: 'User created successfully'
        else
            render 'new'
        end
    end
end
class UsersController
型号:

class User < ActiveRecord::Base
  has_secure_password

  attr_accessible :email, :password, :password_confirmation

  validates_uniqueness_of :email
end
class用户
用户#新表格:

注册表格
当我尝试转到新的用户表单时,它抛出了一个NoMethodError-未定义的方法“email”,指的是带有“f.text\u字段:email”的行

我错过了什么


感谢您的帮助。

您的
用户
表没有
电子邮件
列。请运行迁移以将列添加到您的
users
表中。

是否运行迁移以创建包含所述列的users表。users表中是否有“email”字段?您是对的@techvinet。在教程中,Ryan运行了以下命令:
$rails g resource user email password\u digest
。这给了他表格中名为
email
password\u digest
的列。但当我运行该命令时,它只给了我一个名为
password\u digest
的列。我需要在用户表中添加一个名为
email
的新列。您的用户表没有email字段/列。请先运行迁移以创建一个包含email列的用户表……@user2623004这听起来很奇怪。它应该在表中自动创建电子邮件字段,但若并没有,您可以创建自己的迁移并添加它。
<h1>Sign up form</h1>

<%= form_for @user do |f| %>

    <%= f.label :email %>
    <%= f.text_field :email %>

    <%= f.label :password %>
    <%= f.password_field :password %>

    <%= f.label :password_confirmation %>
    <%= f.password_field :password_confirmation %>

    <%= f.submit %>

<% end %>