Hey everyone,
I was wondering if its possible that something like this:
validates_presence_of :image_1
is only run when in a particular :action.
Petr
Hey everyone,
I was wondering if its possible that something like this:
validates_presence_of :image_1
is only run when in a particular :action.
Petr
petr wrote:
I was wondering if its possible that something like this:
validates_presence_of :image_1
is only run when in a particular :action.
Take a look at the :if parameter in the documentation.
Roderick van Domburg wrote:
petr wrote:
I was wondering if its possible that something like this:
validates_presence_of :image_1
is only run when in a particular :action.
Take a look at the :if parameter in the documentation.
- Roderick
I did, however im not any smarter from it! How would you run a
validation only for action “add” ?
model validations aren’t tied in any way to controller actions, and
you shouldn’t really have a need to this. what i think you might want
to use is the :on option
validates_presence_of :image_1, :on => …
:save - default, validates anytime model is saved (insert or update)
:create - only validates when model is created (insert)
:update - only validates when model is updated (update)
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs