如果我这样编码,我会收到语法错误。
我该如何解决?
before_save :handle_invitation_code, if: :just_confirmed
def just_confirmed?
confirmed_at_changed? && confirmed_at_was.nil?
end
def handle_invitation_code
...
end
如果我这样编码,我会收到语法错误。
我该如何解决?
before_save :handle_invitation_code, if: :just_confirmed
def just_confirmed?
confirmed_at_changed? && confirmed_at_was.nil?
end
def handle_invitation_code
...
end
How about?
before_save :handle_invitation_code
def just_confirmed?
confirmed_at_changed? && confirmed_at_was.nil?
end
def handle_invitation_code
if self.just_confirmed?
...
end
end
Or you would have to pass the code in just_confirmed?
as a Proc to the before_save
.