Ruby on Rails: Polymorphic/Object-agnostic conditions on Trigger setups? -
*i'm not sure concept problem go under - considered polymorphic associations?
i want create system users can set triggers after event happens, event happens.
for example, want user able define trigger action as:
"this [email, document] must sent users after [sign up, read email a, sign document b]."
as can see within brackets "[]", conditions can tied various objects , actions. thought create model triggercondition , storing columns
:object_id, :assigned_to, :activated_when but object_id(email, document) can different models.
would adding column :object_type can either email or document best solution? or there more sophisticated way of designing can pass in object , automatically know i'm referring to?
regarding :activated_when condition, i'm unsure how store , check condition. able use syntax similar "email#marked_as_read(a)?"
i'm trying use rails observers trigger action http://api.rubyonrails.org/v3.2.13/classes/activerecord/observer.html
rails built handle polymorphic associations this.
Comments
Post a Comment