Jsonapi-resources: Disable links

Created on 22 Jan 2016  路  12Comments  路  Source: cerebris/jsonapi-resources

Hi! Thanks for the nice gem again.

I've tried to figured it out myself, but failed. Is there a legal way to disable links to resources? E.g. configuration option?

Thanks!

Most helpful comment

:+1: Turning off links selectively is a strong nice-to-have, as eg. Ember 2.0 issues warnings when included relationships also have links. It would be nice as a rule to have an option just to turn off links for included relationships (or even make that default).

All 12 comments

Doesn't look like it. Was looking for this config option as well. As per the 1.0 spec having a links object is optional so it would be nice to have that reflected here, maybe in the vein of https://github.com/cerebris/jsonapi-resources/blob/master/lib/jsonapi/configuration.rb#L42.

:+1: Turning off links selectively is a strong nice-to-have, as eg. Ember 2.0 issues warnings when included relationships also have links. It would be nice as a rule to have an option just to turn off links for included relationships (or even make that default).

Agree, this would be great.

Does anyone have the _illegal_ way to disable links? I'm about to source dive for it.

Did anyone ever figure out how to do this? This would be a really useful config option.

I'm also curious about this, because if it's nested links are always broken.

Is this being taken care of? :)

Any recommendations on how we can go about disabling links for relationships?

maybe at the end of this paragraph. But I am experiencing problem on creation because of this lines of code. I am still on 0.9 because I'am using mongoid

I've been using this in a Resource:

def custom_links(options)
  {self: nil}
end

@nicolas-besnard

I've been using this in a Resource:

def custom_links(options)
  {self: nil}
end

Does not work for me: undefined method `[]' for nil:NilClass`.

Are you using version 0.10?

With v.0.10.2, use string key instead of symbol key:

def custom_links(options)
  {'self' => nil}
end

Or better way:

class UserResource < JSONAPI::Resource
  exclude_links [:self, :related]
end
Was this page helpful?
0 / 5 - 0 ratings

Related issues

evolve2k picture evolve2k  路  3Comments

lgebhardt picture lgebhardt  路  5Comments

balinterdi picture balinterdi  路  5Comments

mrcasals picture mrcasals  路  4Comments

lcpriest picture lcpriest  路  3Comments