在操作期间生成活动管理员评论

Generate Active Admin Comment during a Action

如何在操作期间在活动管理员评论部分生成评论? (例如,当我将订单状态从 'closed' 更改为 'open' 时)

感谢您以后的回答。

假设您有一个 User 模型,并且您想要为特定用户创建评论。

模型中:

after_update :add_comment

 def add_comment 
  ActiveAdmin::Comment.create(
    resource_id: User.last.id, # id of that particular user to which you add comment
    namespace: 'admin',
    body: 'Your comment body',
    resource_type: 'User',
    author_id: 1, # id of the comment's author, could be AdminUser.first, for example
    author_type: 'AdminUser'
  )
end