[Rails] Re: Validating model depending on controller action
On Oct 26, 10:21 am, Alfredo Bonilla <li...@ruby-forum.com> wrote:
>
> 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.
Sorry not sure what you're asking now
> How would you use the before_validation callback?
It would be pretty much the same except that instead of adding an
error I'd raise some appropriate exception.
Fred
>
> --
> Posted viahttp://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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home