gpt4 book ai didi

ruby-on-rails - 未定义的方法 `email' #<用户 ID : nil, created_at : nil, updated_at: nil>

转载 作者:行者123 更新时间:2023-12-01 01:15:14 27 4
gpt4 key购买 nike

无法弄清楚这里出了什么问题。按照设计设置说明,用谷歌搜索我能想到的一切,仍然没有运气。

undefined method `email' for #<User id: nil, created_at: nil, updated_at: nil>
Extracted source (around line #7):

4: <%= devise_error_messages! %>
5:
6: <div><%= f.label :email %><br />
7: <%= f.email_field :email %></div>
8:
9: <div><%= f.label :password %><br />
10: <%= f.password_field :password %></div>

这是我的用户模型:
class User < ActiveRecord::Base
rolify
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me

validates_presence_of :email
validates_uniqueness_of :email, :case_sensitive => false

end

我已经运行 rake db:migrate,重置服务器,你有什么。仍然无法弄清楚我哪里出错了。我什至有另一个具有相同设置的基本应用程序,通过源代码梳理似乎我已经正确完成了所有操作,只是看不到问题。

最佳答案

基本上你的错误意味着你没有 email您的用户模型中的列(或 attr_accessor)。

我猜您使用的是 Devise < 2.0,现在您使用的是最新版本。

从 2.0 开始,Devise 不再自动将列包含到您的模型中,see this page for more info .

关于ruby-on-rails - 未定义的方法 `email' #<用户 ID : nil, created_at : nil, updated_at: nil>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12442674/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com