How to get the current_user in a model observer?

前端 未结 5 2013
有刺的猬
有刺的猬 2021-01-13 05:35

Given the following models:

Room (id, title)
RoomMembers (id, room_id)
RoomFeed, also an observer

When a Room title is updated, I want to c

5条回答
  •  离开以前
    2021-01-13 05:48

    I think what you are looking for is, room.updated_by inside your observer. If you don't want to persist the updated_by, just declare it as an attr_accessor. Before you push the update, make sure you assign the current_user to updated_by, may be from you controller.

提交回复
热议问题