Leon Leslie
2005-Nov-15 22:58 UTC
How can I have Active Record warn and also report errors?
Hi railers, Is there a simple method to extend Active Record to have the same functionality as the validate functions e.g. validate_on_find validates_acceptance_of validates_each validates_format_of validates_length_of validates_uniqueness_of but report soft errors maybe to an object warn() instead of errors(). maybe functions like: warn_on_find warn_acceptance_of warn_each warn_format_of warn_length_of warn_uniqueness_of I am aware of save_with_validation(perform_validation = false) but we want to prevent saves if the model is invalid, these are just some softer messages which we would like to retrive on find or save. Any help will be greatly appreciated. regards, Leon _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Leon Leslie
2005-Nov-15 23:18 UTC
Re: How can I have Active Record warn and also report errors?
One could achieve this my looking at ActiveRecord::Validations::ClassMethods and ActiveRecord::Validations in vendor/rails/activerecord/lib/active_record/validations.rb<http://api.rubyonrails.org/files/vendor/rails/activerecord/lib/active_record/validations_rb.html>but is just does feel like the DRY method.. Any other suggestions? On 11/15/05, Leon Leslie <leonleslie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi railers, > > Is there a simple method to extend Active Record to have the same > functionality as the validate functions e.g. > > validate_on_find > validates_acceptance_of > validates_each > validates_format_of > validates_length_of > validates_uniqueness_of > > but report soft errors maybe to an object warn() instead of errors(). > maybe functions like: > > warn_on_find > warn_acceptance_of > warn_each > warn_format_of > warn_length_of > warn_uniqueness_of > > I am aware of save_with_validation(perform_validation = false) but we want > to prevent saves if the model is invalid, these are just some softer > messages which we would like to retrive on find or save. > > Any help will be greatly appreciated. > > regards, > Leon > >-- First they laugh at you, then they ignore you, then they fight you. Then you win. -- Mahatma Karamchand Gandhi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Leon Leslie
2005-Nov-17 16:56 UTC
Re: How can I have Active Record warn and also report errors?
rewriting a module like ActiveRecord:Validations does not seem to be the DRY (Don''t Repeat Yourself) method. Is there any other method to have warnings on a model? On 11/15/05, Leon Leslie <leonleslie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > One could achieve this my looking at ActiveRecord::Validations::ClassMethods > and ActiveRecord::Validations in > vendor/rails/activerecord/lib/active_record/validations.rb > <http://api.rubyonrails.org/files/vendor/rails/activerecord/lib/active_record/validations_rb.html>but is just does feel like the DRY method.. > > Any other suggestions? > > > > On 11/15/05, Leon Leslie <leonleslie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi railers, > > > > Is there a simple method to extend Active Record to have the same > > functionality as the validate functions e.g. > > > > validate_on_find > > validates_acceptance_of > > validates_each > > validates_format_of > > validates_length_of > > validates_uniqueness_of > > > > but report soft errors maybe to an object warn() instead of errors(). > > maybe functions like: > > > > warn_on_find > > warn_acceptance_of > > warn_each > > warn_format_of > > warn_length_of > > warn_uniqueness_of > > > > I am aware of save_with_validation(perform_validation = false) but we > > want to prevent saves if the model is invalid, these are just some softer > > messages which we would like to retrive on find or save. > > > > Any help will be greatly appreciated. > > > > regards, > > Leon > > > > > > > -- > First they laugh at you, then they ignore you, then they fight you. > Then you win. > -- Mahatma Karamchand Gandhi-- First they laugh at you, then they ignore you, then they fight you. Then you win. -- Mahatma Karamchand Gandhi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails