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 -- 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. > > - RoderickI did, however im not any smarter from it! How would you run a validation only for action "add" ? -- 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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) On 11/21/06, Guest <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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" ? > > -- > 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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---