Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude/Include of relationships #3

Closed
myabc opened this issue Dec 10, 2016 · 2 comments
Closed

Exclude/Include of relationships #3

myabc opened this issue Dec 10, 2016 · 2 comments
Assignees

Comments

@myabc
Copy link
Collaborator

myabc commented Dec 10, 2016

From @wuarmin on September 20, 2016 17:59

At http://trailblazer.to/gems/representable/3.0/api.html#include-and-exclude there's a documenation about the top-level-options include and exclude. Today I tried to exclude a has_many relationship while using Roar::JSON::JSONAPI, but can't achieve it.

class ArticleDecorator < Roar::Decorator
  include Roar::JSON::JSONAPI
  type :articles
# a property exclude works
  property :id
  property :title
# a relationship exclude does not work
  has_one :author, class: Author, populator: ::Representable::FindOrInstantiate do 
    type :authors
    property :id
    property :email
  end
end
#===============================================
ArticleDecorator.new(article).to_json(exclude: [:title]) #works
ArticleDecorator.new(article).to_json(exclude: [:author]) # does not work

Is the feature limited to properties?

Copied from original issue: trailblazer/roar#199

@myabc
Copy link
Collaborator Author

myabc commented Jan 5, 2017

@wuarmin

Is the feature limited to properties?

Yes, it's currently limited to scalar attributes..

Note that ArticleDecorator.new(article).to_json(include: [:author]) probably doesn't do what you expect either.

@myabc
Copy link
Collaborator Author

myabc commented Jan 9, 2017

@wuarmin as with #2, this should now be fixed on master.

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

No branches or pull requests

1 participant