I have two related models - let's say Activity
and Step
. Activity has_many :steps
and Step belongs_to :activity
which means the table for steps
has an activity_id
column.
This is in Hobo 1.3, so Rails 3.0.
What I want is to ensure that after Step
creation it is not possible to move a step to another Activity
. We don't want the activity_id
field to change.
I've removed the field from edit forms, but I'm looking for a stronger constraint. Essentially I want to validate on update
(not on create
) that the column isn't being touched. Hobo's documentation doesn't suggest anything of the sort inside Hobo, so I'm looking at Rails validations, but so far I haven't found the "only do this on update" constraint that I remember, nor a validation that something isn't changing.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…