Frederick C. wrote in post #957145:
On Oct 26, 9:36am, Alfredo B. [email protected] wrote:
controller reopen action?"
Models (quite rightly) have no concept of controller actions. If you
want to do this then you have to change some of the model’s state (eg
set an instance variable) when reopen is called and check that in your
A validation doesn’t feel quite right to me. While it sounds like you
can probably do what you want it sounds like you are stretching the
semantics slightly: it’s not that a particular combination of
attributes that are invalid, it’s a set of transitions that are
invalid. I’d be more inclined to write a before_validation callback
Thanks for your answer. I would use the instance variable, but if my
code in the model looks like:
errors.add(:minutes_closed, “specifies that the board is closed.
To reopen, use contextual menu action.”)
where minutes_closed is the boolean field that just can be passed from
true to false by executing the “reopen” action.
How would you use the before_validation callback?