Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5112 (new enhancement)

Opened 2 years ago

Last modified 2 years ago

[PATCH] validation defaults should be overridable and consistently applied

Reported by: anonymous Assigned to: David
Priority: low Milestone: 2.x
Component: ActiveRecord Version: 1.1.1
Severity: normal Keywords: validation allow_nil
Cc:

Description

This is ass backwards and requires typing :allow_nil => true over and over. I used to have a patch that worked by changing DEFAULT_VALIDATION_OPTIONS. But it seems the validations programmers have now hard coded the defaults into every routine.

So even if I don't agree I can't change it without rewriting the entire validation package.

So now it's not just ass backwards, it difficult to change and being forced down my throat.

AT LEAST ALLOW FOR CHOICE IN THIS MATTER EVEN IF YOU DON'T AGREE.

Attachments

allow_nil.patch (9.0 kB) - added by anonymous on 06/29/06 21:21:21.
[PATCH] Configurable allow_nil

Change History

05/17/06 18:46:00 changed by bitsweat

  • keywords set to validation allow_nil.
  • priority changed from normal to low.
  • summary changed from validations default to :allow_nil => false to validation defaults should be overridable and consistently applied.
  • type changed from defect to enhancement.
  • milestone set to 1.x.

I'm sorry it's been such a thorn in your side. I suggest you update the validates_* methods to do options = DEFAULT_VALIDATIONS_OPTIONS.merge(options) and verify that behavior with corresponding unit tests.

Then consider a way to configure the defaults application-wide, such as a setting in config/environment.rb. By making DEFAULT_VALIDATIONS_OPTIONS a class attribute of ActiveRecord::Base we could do config.active_record.default_validation_options = { ... }. Unit test this as well.

If all goes well, attach your well-tested patch here, prefix the summary with [PATCH], and you're golden.

Thanks!

06/29/06 21:21:21 changed by anonymous

  • attachment allow_nil.patch added.

[PATCH] Configurable allow_nil

06/30/06 18:12:04 changed by anonymous

  • summary changed from validation defaults should be overridable and consistently applied to [PATCH] validation defaults should be overridable and consistently applied.