We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 5eb0869 + 614c07a commit c358cb7Copy full SHA for c358cb7
2 files changed
lib/jsonapi/relationship.rb
@@ -74,7 +74,7 @@ def belongs_to?
74
end
75
76
def polymorphic_type
77
- "#{type.to_s.singularize}_type" if polymorphic?
+ "#{name}_type" if polymorphic?
78
79
80
test/unit/resource/relationship_test.rb
@@ -0,0 +1,12 @@
1
+require File.expand_path('../../../test_helper', __FILE__)
2
+
3
+class HasOneRelationshipTest < ActiveSupport::TestCase
4
5
+ def test_polymorphic_type
6
+ relationship = JSONAPI::Relationship::ToOne.new("imageable",
7
+ polymorphic: true
8
+ )
9
+ assert_equal(relationship.polymorphic_type, "imageable_type")
10
+ end
11
12
+end
0 commit comments