Prevent change of one field in Rails model

前端 未结 3 1727
执念已碎
执念已碎 2020-12-14 08:06

I have two related models - let\'s say Activity and Step. Activity has_many :steps and Step belongs_to :activity which me

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 09:07

    I think you can do this too with the Hobo permissions system: http://hobocentral.net/manual/permissions

    For example:

    def update_permitted?
      acting_user.administrator && !activity_id_changed?
    end
    

提交回复
热议问题