aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-03-14 20:17:03 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2014-03-14 20:30:55 -0300
commitbae7f1dae90c37b0e02482a1d99f4aeec5d49e24 (patch)
tree92ab9b0a56ba77c804a8601d8537bfeb76c1efb8 /activerecord/test/models
parenteb31a86f3090b04a7171c4db054ad0ec98cac760 (diff)
downloadrails-bae7f1dae90c37b0e02482a1d99f4aeec5d49e24.tar.gz
rails-bae7f1dae90c37b0e02482a1d99f4aeec5d49e24.tar.bz2
rails-bae7f1dae90c37b0e02482a1d99f4aeec5d49e24.zip
Obey `validate: false` option for habtm
Fixes #14383.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/person.rb13
-rw-r--r--activerecord/test/models/treasure.rb1
2 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb
index 1a282dbce4..c7e54e7b63 100644
--- a/activerecord/test/models/person.rb
+++ b/activerecord/test/models/person.rb
@@ -89,6 +89,19 @@ class RichPerson < ActiveRecord::Base
self.table_name = 'people'
has_and_belongs_to_many :treasures, :join_table => 'peoples_treasures'
+
+ before_validation :run_before_create, on: :create
+ before_validation :run_before_validation
+
+ private
+
+ def run_before_create
+ self.first_name = first_name.to_s + 'run_before_create'
+ end
+
+ def run_before_validation
+ self.first_name = first_name.to_s + 'run_before_validation'
+ end
end
class NestedPerson < ActiveRecord::Base
diff --git a/activerecord/test/models/treasure.rb b/activerecord/test/models/treasure.rb
index e864295acf..a69d3fd3df 100644
--- a/activerecord/test/models/treasure.rb
+++ b/activerecord/test/models/treasure.rb
@@ -3,6 +3,7 @@ class Treasure < ActiveRecord::Base
belongs_to :looter, :polymorphic => true
has_many :price_estimates, :as => :estimate_of
+ has_and_belongs_to_many :rich_people, join_table: 'peoples_treasures', validate: false
accepts_nested_attributes_for :looter
end