diff options
author | Kevin Casey <kacasey@berkeley.edu> | 2014-02-08 08:44:10 -0800 |
---|---|---|
committer | Kevin Casey <kacasey@berkeley.edu> | 2014-02-08 08:44:10 -0800 |
commit | 5e3d466d52fa4e9a42c3a1f8773a7c31da875e48 (patch) | |
tree | c20bd22beae53899e630c6cbf27c0c5401dad929 /activerecord/test/models | |
parent | ed66361488752aa115f8d95175cde6dd24f3496d (diff) | |
download | rails-5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.tar.gz rails-5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.tar.bz2 rails-5e3d466d52fa4e9a42c3a1f8773a7c31da875e48.zip |
context in validation goes through has many relationship
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/pirate.rb | 8 | ||||
-rw-r--r-- | activerecord/test/models/ship.rb | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/models/pirate.rb b/activerecord/test/models/pirate.rb index 7bb0caf44b..8510c596a7 100644 --- a/activerecord/test/models/pirate.rb +++ b/activerecord/test/models/pirate.rb @@ -85,3 +85,11 @@ end class DestructivePirate < Pirate has_one :dependent_ship, :class_name => 'Ship', :foreign_key => :pirate_id, :dependent => :destroy end + +class FamousPirate < ActiveRecord::Base + self.table_name = 'pirates' + + has_many :famous_ships + + validates_presence_of :catchphrase, on: :conference +end diff --git a/activerecord/test/models/ship.rb b/activerecord/test/models/ship.rb index 3da031946f..7a369b9d9a 100644 --- a/activerecord/test/models/ship.rb +++ b/activerecord/test/models/ship.rb @@ -17,3 +17,11 @@ class Ship < ActiveRecord::Base false end end + +class FamousShip < ActiveRecord::Base + self.table_name = 'ships' + + belongs_to :famous_pirate + + validates_presence_of :name, on: :conference +end |