aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/company.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-25 12:06:04 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-25 12:06:04 -0700
commitd1e36842ba8f3eb723fd65535cf292c898c73b68 (patch)
treea45f80d31148a40b095ae572eb76d468ce1df66d /activerecord/test/models/company.rb
parente2fd64fe469037644711a65a00270bea15ee2955 (diff)
parent25ada9b5411808c4ae8dc72ba99cc09fe10ff884 (diff)
downloadrails-d1e36842ba8f3eb723fd65535cf292c898c73b68.tar.gz
rails-d1e36842ba8f3eb723fd65535cf292c898c73b68.tar.bz2
rails-d1e36842ba8f3eb723fd65535cf292c898c73b68.zip
Merge pull request #12359 from arthurnn/inverse_on_callbacks
Make sure inverse_of is visible on the has_many callbacks
Diffstat (limited to 'activerecord/test/models/company.rb')
-rw-r--r--activerecord/test/models/company.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb
index 8104c607b5..1aa77f95bf 100644
--- a/activerecord/test/models/company.rb
+++ b/activerecord/test/models/company.rb
@@ -39,7 +39,7 @@ class Firm < Company
has_many :unsorted_clients, :class_name => "Client"
has_many :unsorted_clients_with_symbol, :class_name => :Client
has_many :clients_sorted_desc, -> { order "id DESC" }, :class_name => "Client"
- has_many :clients_of_firm, -> { order "id" }, :foreign_key => "client_of", :class_name => "Client"
+ has_many :clients_of_firm, -> { order "id" }, :foreign_key => "client_of", :class_name => "Client", :inverse_of => :firm
has_many :clients_ordered_by_name, -> { order "name" }, :class_name => "Client"
has_many :unvalidated_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :validate => false
has_many :dependent_clients_of_firm, -> { order "id" }, :foreign_key => "client_of", :class_name => "Client", :dependent => :destroy
@@ -117,6 +117,10 @@ class Client < Company
has_many :accounts, :through => :firm, :source => :accounts
belongs_to :account
+ validate do
+ firm
+ end
+
class RaisedOnSave < RuntimeError; end
attr_accessor :raise_on_save
before_save do