On Oct 26, 9:36 am, Alfredo Bonilla <li...@ruby-forum.com> wrote:
> Hi,
>
> I have a custom validation in my model, reviewing the content of some
> field. This field indicates that the record is "closed", so it can not
> be modified.
>
> The only way to "reopen" the record is by executing an specific model
> action: reopen.
>
> So my question is: "how can I avoid to validate this field JUST for the
> 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

-- 
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.

Reply via email to