aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorMike Breen <hardbap@gmail.com>2009-05-10 15:02:00 +1200
committerMichael Koziarski <michael@koziarski.com>2009-05-10 15:02:00 +1200
commit9010ed27559ed5ab89ea71b4b16f4c8e56d03dbb (patch)
treecc6198a10a89e8a7017f2f38368e94bdd8348ad6 /activerecord/test/models
parent026b78f9076216990bddb1aa5d83d23a647c02a5 (diff)
downloadrails-9010ed27559ed5ab89ea71b4b16f4c8e56d03dbb.tar.gz
rails-9010ed27559ed5ab89ea71b4b16f4c8e56d03dbb.tar.bz2
rails-9010ed27559ed5ab89ea71b4b16f4c8e56d03dbb.zip
Allow you to pass :all_blank to :reject_if option to automatically create a Proc that will reject any record with blank attributes.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/pirate.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activerecord/test/models/pirate.rb b/activerecord/test/models/pirate.rb
index 238917bf30..acf53fce8b 100644
--- a/activerecord/test/models/pirate.rb
+++ b/activerecord/test/models/pirate.rb
@@ -28,11 +28,13 @@ class Pirate < ActiveRecord::Base
:after_add => proc {|p,b| p.ship_log << "after_adding_proc_bird_#{b.id || '<new>'}"},
:before_remove => proc {|p,b| p.ship_log << "before_removing_proc_bird_#{b.id}"},
:after_remove => proc {|p,b| p.ship_log << "after_removing_proc_bird_#{b.id}"}
+ has_many :birds_with_reject_all_blank, :class_name => "Bird"
accepts_nested_attributes_for :parrots, :birds, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? }
accepts_nested_attributes_for :parrots_with_method_callbacks, :parrots_with_proc_callbacks,
:birds_with_method_callbacks, :birds_with_proc_callbacks, :allow_destroy => true
+ accepts_nested_attributes_for :birds_with_reject_all_blank, :reject_if => :all_blank
validates_presence_of :catchphrase