From 04852b875ec5c2bd5e5f8bf525b7be60682d0c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 30 Dec 2014 20:59:27 -0300 Subject: Fix error message when trying to create an associated record This error only happens when the foreign key is missing. Before this fix the following exception was being raised: NoMethodError: undefined method `val' for # Now the message is: ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model. --- activerecord/test/models/company.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/test/models/company.rb') diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb index 42f7fb4680..5a56616eb9 100644 --- a/activerecord/test/models/company.rb +++ b/activerecord/test/models/company.rb @@ -72,6 +72,7 @@ class Firm < Company # Oracle tests were failing because of that as the second fixture was selected has_one :account_using_primary_key, -> { order('id') }, :primary_key => "firm_id", :class_name => "Account" has_one :account_using_foreign_and_primary_keys, :foreign_key => "firm_name", :primary_key => "name", :class_name => "Account" + has_one :account_with_inexistent_foreign_key, class_name: 'Account', foreign_key: "inexistent" has_one :deletable_account, :foreign_key => "firm_id", :class_name => "Account", :dependent => :delete has_one :account_limit_500_with_hash_conditions, -> { where :credit_limit => 500 }, :foreign_key => "firm_id", :class_name => "Account" -- cgit v1.2.3