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
I get an error at user_is_new=...
NoMethodError (undefined method `now ' for Time:Class):
WHY this error pops?
I have already test in rails console and works fine, but in a request crash
Remove (replace) the (non-ascii?)space near the minus
user_is_new = Time.now-user.created_at < 30
NoMethodError (undefined method `now ' for Time:Class):
It says now
not now
or as in any other case, where the method can't be found. Try deleting the space right after the now
method name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.