JsonApiClient / json_api_client

Build client libraries compliant with specification defined by jsonapi.org
MIT License
361 stars 186 forks source link

Fix/initializing resources with associations of dashed types #373

Closed inderps closed 3 years ago

inderps commented 3 years ago

If you have resource with associations of dashed types. You cannot access those associations because of the bug

# {
#   id: 1,
#   type: 'dashed-owners',
#   attributes: {
#     name: "Arjuna"
#   }
# }

class DashedOwner < Formatted
end

class DashedProperty < Formatted
  has_one :dashed_owner
end

dashed_owner = DashedOwner.find(1).first
dashed_property = DashedProperty.new(dashed_owner: dashed_owner)

Accessing below will results in following error

dashed_property.dashed_owner

NameError: uninitialized constant DashedProperty::Dashed-owner