Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Attribute check for belongs_to resolution #12

Open
marktran opened this issue Jan 17, 2015 · 0 comments
Open

Attribute check for belongs_to resolution #12

marktran opened this issue Jan 17, 2015 · 0 comments

Comments

@marktran
Copy link
Contributor

class Resource < Daylight::API
  belongs_to :owner
end

ActiveResource supports (rails/activeresource#50) resolving a belongs_to association via a foreign key:

r = Resource.first 
=> {
  ...
  "owner_id": 42
}

or through the attribute name:

r = Resource.first 
=> {
  ...
  "owner": {
    ...
  }
}

It looks like Daylight is failing on the latter since it expects the foreign key to be present.

Relevant line:

reflection.klass.find(send(reflection.foreign_key))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant