diff --git a/lib/friendly_id/base.rb b/lib/friendly_id/base.rb index b71552fd9..e3c2a5e53 100644 --- a/lib/friendly_id/base.rb +++ b/lib/friendly_id/base.rb @@ -222,7 +222,7 @@ def friendly_id_config end def primary_key_type - @primary_key_type ||= columns.find(&:primary).type + @primary_key_type ||= columns.find { |c| c.name == primary_key}.type end end diff --git a/test/slugged_test.rb b/test/slugged_test.rb index ad50ff17e..1f51c881f 100644 --- a/test/slugged_test.rb +++ b/test/slugged_test.rb @@ -265,7 +265,7 @@ def model_class test "should have a string as a primary key" do assert_equal model_class.primary_key, "string_key" - assert_equal model_class.columns.find(&:primary).name, "string_key" + assert_equal model_class.columns.find { |c| c.name == model_class.primary_key}.name, "string_key" end test "should be findable by the string primary key" do