我需要知道模型中当前用户的 ID:
def after_save
desc, points=nil, nil
if answer_index == daily_question.correct_answer_index
desc = I18n.t('daily_question.point_log.description.correct')
points=daily_question.points
else
desc = I18n.t('daily_question.point_log.description.incorrect')
end
current_user.give_points(:description => desc,
:points => points
)
end
但我想这不是怎么做的?
Regards,
Jacob
假设用户已登录,您可以使用
UserSession.find.user
您可能需要添加检查以确保UserSession.find
在调用之前返回一些内容.user
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)