新手问题 Rails 中 Model 的属性验证出错 undefined local variable or method

BigNerdCoding · December 12, 2016 · Last by BigNerdCoding replied at December 13, 2016 · 1249 hits

最近开始学 Rails,买了安道的书。在做练习的时候出现了一个很奇怪的问题:

class User < ApplicationRecord
    validates name, presence: true
    validates email, presence: true
end

加上 email 的验证会出现如下图所示错误,百思不解。希望能够得到解答

应该是 :name, :email

#1 楼 @kayakjiang 很感谢。看样子还是需要先 Ruby 后 Rails。

BigNerdCoding closed this topic. 13 Dec 19:42
BigNerdCoding reopened this topic. 13 Dec 19:43

#5 楼 @BigNerdCoding #1 楼 已经指出问题所在了。

#6 楼 @lgn21st 是的,解决了。谢谢

huacnlee closed this topic. 14 Dec 10:04
You need to Sign in before reply, if you don't have an account, please Sign up first.