Frederick Cheung wrote in post #957145: > On Oct 26, 9:36am, Alfredo Bonilla <li...@ruby-forum.com> 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 > validation. > 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 > > Fred
Thanks for your answer. I would use the instance variable, but if my code in the model looks like: validate :minutes_editable ... def minutes_editable if minutes_closed_was errors.add(:minutes_closed, "specifies that the board is closed. To reopen, use contextual menu action.") end end 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? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.