I would like to know if there is a way to use rail checks in a user action.
For example, I would like to do something like this:
validates_presence_of :description, :on => :publish, :message => "can't be blank"
I do basic checks, create and save, but there are so many things that I do not want to demand ahead. That is, they should be able to save a painless record without checking all fields, however, I have a custom “publish” action and a state in my controller and model, which when used should be checked to make sure that the record is 100%
The above example does not work, any ideas?
UPDATE:
My state machine looks like this:
include ActiveRecord::Transitions
state_machine do
state :draft
state :active
state :offline
event :publish do
transitions :to => :active, :from => :draft, :on_transition => :do_submit_to_user, :guard => :validates_a_lot?
end
end
I found that I could add defenders, but still I would like to use rail checks instead of doing all this using a special method.