在此反射中,我想将 lastupdateby 字段设置为 current_user。我还没能让它发挥作用。我需要做些什么才能在反射中获得该值吗?对我做错了什么有什么想法吗?如果我硬编码该值而不是 current_user ,它就可以工作。我一定是引用错了。
def toggle
todo = Todo.find(element.dataset[:id])
todo.update(completed_at: (todo.completed_at? ? nil : Time.current), lastUpdatedBy: current_user)
end
最佳答案
关于ruby-on-rails - 如何访问stimulus_reflex中的current_user,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64279653/