File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
lib/active_record/attribute_methods Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -24,11 +24,13 @@ def reset_primary_key #:nodoc:
2424 end
2525
2626 def get_primary_key ( base_name ) #:nodoc:
27+ return unless base_name
28+
2729 case primary_key_prefix_type
2830 when :table_name
29- base_name . to_s . foreign_key ( false )
31+ base_name . foreign_key ( false )
3032 when :table_name_with_underscore
31- base_name . to_s . foreign_key
33+ base_name . foreign_key
3234 else
3335 'id'
3436 end
Original file line number Diff line number Diff line change @@ -1069,6 +1069,7 @@ def test_define_attr_method_with_value
10691069
10701070 def test_define_attr_method_with_block
10711071 k = Class . new ( ActiveRecord ::Base )
1072+ k . primary_key = "id"
10721073 k . send ( :define_attr_method , :primary_key ) { "sys_" + original_primary_key }
10731074 assert_equal "sys_id" , k . primary_key
10741075 end
@@ -1109,6 +1110,7 @@ def test_set_primary_key_with_value
11091110
11101111 def test_set_primary_key_with_block
11111112 k = Class . new ( ActiveRecord ::Base )
1113+ k . primary_key = 'id'
11121114 k . set_primary_key { "sys_" + original_primary_key }
11131115 assert_equal "sys_id" , k . primary_key
11141116 end
You can’t perform that action at this time.
0 commit comments