class Email < ActiveRecord::Base
# some code
after_create :send_verification_email
def send_verification_email
puts 'edit 1', Time.now # it prints the actual date
user_is_new = Time.now - user.created_at < 30 # This line pops an error
unless verified || user_is_new # less than 30 seconds
#some other code
我在user_is_new = ...
时收到错误消息NoMethodError (undefined method `now ' for Time:Class):
为什么会出现此错误?
我已经在rails控制台中测试并且工作正常,但是在请求崩溃中
删除(替换)减号
附近的(非ascii?)空格user_is_new = Time.now-user.created_at < 30
答案 0 :(得分:2)
NoMethodError (undefined method `now ' for Time:Class):
它表示now
不是now
或任何其他情况下无法找到方法。请尝试在now
方法名称后面删除空格。