Skip to content

Commit 42da412

Browse files
committed
Bug fix: Allow multiple relationships to be defined in one declaration.
1 parent 7ebba9b commit 42da412

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

lib/jsonapi/resource.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ def define_relationship_methods(relationship_name, relationship_klass, options)
913913
if _model_class && _model_class.ancestors.collect { |ancestor| ancestor.name }.include?('ActiveRecord::Base')
914914
model_association = _model_class.reflect_on_association(relationship_name)
915915
if model_association
916-
options[:class_name] ||= model_association.class_name
916+
options = options.reverse_merge(class_name: model_association.class_name)
917917
end
918918
end
919919

test/fixtures/active_record.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,7 @@ class PersonResource < BaseResource
936936
attributes :name, :email
937937
attribute :date_joined, format: :date_with_timezone
938938

939-
has_many :comments
940-
has_many :posts
939+
has_many :comments, :posts
941940
has_many :vehicles, polymorphic: true
942941

943942
has_one :preferences

0 commit comments

Comments
 (0)