我有一个模型,在状态列上有一个状态机,管理员和普通用户都可以更改。如何实施仅允许管理员触发特定事件的保护层?例如:
state_machine :status, initial: :draft do
# A user can change the status of his model to be reviewed
event :review do
transition draft: :in_review
end
# Only an admin can approve or disapprove
event :approve do
transition in_review: :approved
end
event :disapprove do
transition in_review: :disapproved
end
end
谢谢!