cerebris / jsonapi-resources

A resource-focused Rails library for developing JSON:API compliant servers.
http://jsonapi-resources.com
MIT License
2.32k stars 532 forks source link

parse_to_one_relationship should read model name from realationship first #1122

Closed cs3b closed 7 years ago

cs3b commented 7 years ago
class Mm::KudoResource < JSONAPI::Resource
  model_name 'Mm::Kudo'
  attributes :value, :tags, :comment

  has_one :giver, class_name: '::Contractor', controller: '/contractors'
end

class ContractorResource < JSONAPI::Resource
  model_name 'Coworker'
  has_many :kudos_given, class_name: 'Mm::Kudo', controller: 'mm/kudos'
end

When parse_to_one_relationship try to guess relationship_resource it should first look on the relationship.class_name, and only if its not defined take it from the type.

cs3b commented 7 years ago

On master it is already fixed ... my bad

https://github.com/cerebris/jsonapi-resources/blob/master/lib/jsonapi/request_parser.rb#L539

When there is plan for next release?

thanks :-)