One of the things that strikes me as odd about the validations as I understand them to work from AWDWR, is that the validations themselves are only triggered upon a save. I brought this up earlier that I am accustomed to doing validations of data before updating a model with it, but Rails wants to allow the modification of the model, then only bother to validate it if it is saved -- at least that''s what I''m seeing at this point. What good does that do unsaved model data? Model data that perhaps never gets saved to a database, but nonetheless must have validated data to perform its interim purpose. What if I bring data in from a web service or a file -- isn''t it best to complain to that source (or log the problem, or whatever) at the moment the data is accepted, and not some who-knows-when point which may be tainted by some other process and therefore I lose the ability to complain to the actual source that provided the bad data? Looking at the methods in validations.rb, I''m not seeing a method that gives me arbitrary control over when to invoke validations. I''m probably still not seeing the whole picture, but I''m getting that "something''s wrong" feeling. -- gw (www.railsdev.ws) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 11/27/07, Greg Willits <lists-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote:> > One of the things that strikes me as odd about the validations as I > understand them to work from AWDWR, is that the validations > themselves are only triggered upon a save. > > I brought this up earlier that I am accustomed to doing validations > of data before updating a model with it, but Rails wants to allow the > modification of the model, then only bother to validate it if it is > saved -- at least that''s what I''m seeing at this point. > > What good does that do unsaved model data? Model data that perhaps > never gets saved to a database, but nonetheless must have validated > data to perform its interim purpose. > > What if I bring data in from a web service or a file -- isn''t it best > to complain to that source (or log the problem, or whatever) at the > moment the data is accepted, and not some who-knows-when point which > may be tainted by some other process and therefore I lose the ability > to complain to the actual source that provided the bad data? > > Looking at the methods in validations.rb, I''m not seeing a method > that gives me arbitrary control over when to invoke validations. > > I''m probably still not seeing the whole picture, but I''m getting that > "something''s wrong" feeling. > > > -- gw (www.railsdev.ws) > > > > > > >my_object.valid? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
if you create a validate function, which automatically gets called by rails you can do my_object.validate there are 2 others validate_on_create and validate_on_update the my_object.valid? method should invoke these and any of the validates_X functions and if you want something that is unique to this data and that doesn''t get saved on create your own method and call my_object.my_method_name White Wizzard On Nov 27, 4:23 am, "Pat Maddox" <perg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 11/27/07, Greg Willits <li...-0Bv1hcaDFPRk211Z5VL+QA@public.gmane.org> wrote: > > > > > > > One of the things that strikes me as odd about the validations as I > > understand them to work from AWDWR, is that the validations > > themselves are only triggered upon a save. > > > I brought this up earlier that I am accustomed to doing validations > > of data before updating a model with it, but Rails wants to allow the > > modification of the model, then only bother to validate it if it is > > saved -- at least that''s what I''m seeing at this point. > > > What good does that do unsaved model data? Model data that perhaps > > never gets saved to a database, but nonetheless must have validated > > data to perform its interim purpose. > > > What if I bring data in from a web service or a file -- isn''t it best > > to complain to that source (or log the problem, or whatever) at the > > moment the data is accepted, and not some who-knows-when point which > > may be tainted by some other process and therefore I lose the ability > > to complain to the actual source that provided the bad data? > > > Looking at the methods in validations.rb, I''m not seeing a method > > that gives me arbitrary control over when to invoke validations. > > > I''m probably still not seeing the whole picture, but I''m getting that > > "something''s wrong" feeling. > > > -- gw (www.railsdev.ws) > > my_object.valid?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---