Questions tagged [jsonapi-resources]

JSONAPI-Resources is a Ruby library to write clients and servers for the JSONAPI standard.

JSONAPI-Resources is a Ruby library to write clients and servers for the JSON API standard.

JSONAPI may be regarded as a set of best practices for writing JSON-based APIs, or as an actual standard. JR's github page serves as its home page and the author's blog contains some introductory postings.

111 questions
0
votes
2 answers

Rails.cache.fetch does not work for array of json

I am trying to cache server API response using Rail.cache.fetch feature but it seems like just always 'nil' instead cached data. Method below runs one time, then always fails with 'access to nil class' kind error when I am trying to go through…
Vitali Grabovski
  • 183
  • 1
  • 3
  • 14
0
votes
1 answer

How i can fix JSONAPI::Serializable::UndefinedSerializableClass

How I can fix: ERROR: JSONAPI::Serializable::UndefinedSerializableClass: No serializable class defined for Post app/controllers/api/v1/posts_controller.rb:20:in `index' Using this gems: gem 'jsonapi_suite' gem 'jsonapi-rails'
Mohamed Ziata
  • 1,186
  • 1
  • 11
  • 21
0
votes
1 answer

Json API Include filter not working

I have an issue, I want to apply filter on included data but it's not working here is the scenario API…
0
votes
1 answer

Filter by a field of a join table using JSONAPI Resources

I have three tables: Observation Subcategory Category with the following structure: class Observation < ApplicationRecord translates :name belongs_to :subcategory end class Subcategory < ApplicationRecord belongs_to :category has_many…
Tiago
  • 673
  • 1
  • 8
  • 24
0
votes
1 answer

How to fix an API using jsonapi-resources that is responding with mismatch type and not allowing me to create records?

I have a problem with Mismatch types in my API everytime I want to create a new item. It happens in 2 places: when I try to POST a new item POST http://localhost:8060/datasets/ { "data": { "type": "datasets", …
0
votes
1 answer

JSONAPI should the endpoint URL match exactly the `type` of a resource

I am building a jsonapi for my website, and while looking at various frontend components I came across https://github.com/dixieio/redux-json-api/tree/master/docs Which seems to resolve the endpoint URL directly from the resource type It is part of…
Cyril Duchon-Doris
  • 12,964
  • 9
  • 77
  • 164
0
votes
1 answer

Ruby jsonapi-resources links (relative/absolute)

I am incredibly new to Ruby, so I apologise in advance if this question seems very simple or vague. Where, when using jsonapi-resources is the base path for JSON API links specified? I wish to change from specifying full URLs to root-relative paths…
vogomatix
  • 4,856
  • 2
  • 23
  • 46
0
votes
2 answers

jsonapi-resources—overriding fields

There's a field in my resource that I want to set to 1 if it's nil in the model. I have the following code, but the resource is still producing minimum_approvers: nil Any ideas on what's going on? module V1 class EntityResource < BaseResource …
Mirror318
  • 11,875
  • 14
  • 64
  • 106
0
votes
1 answer

Removing links using JasonApi Resources Gem

I have a simple model with the following classes: class Country < ApplicationRecord has_many :country_categories has_many :categories, through: :country_categories end class CountryCategory < ApplicationRecord belongs_to :country belongs_to…
Tiago
  • 673
  • 1
  • 8
  • 24
0
votes
0 answers

Optimizing garbage collection with jsonapi-resources

I am currently using the jsonapi-resources gem in my Rails 5 application and I'm very happy with that. To optimize RAM consumption I wanna replace the .all call in my controller with the following: def index @cars = [] Car.find_each do…
Severin
  • 8,508
  • 14
  • 68
  • 117
0
votes
1 answer

JSON API delete 'has and belongs to many' relationship

I'm building an API for a cart-like thing with the jsonapi-resources gem, and I need an endpoint to remove an item from the cart. Currently, I'm assuming that a client consuming this API won't need the actual 'cart items'. Instead it just needs a…
Obversity
  • 567
  • 2
  • 9
  • 21
0
votes
2 answers

Convert a string from web service to JSON array

I want to convert this web service string to JSONArray , but it seems to have a problem , although I've validated it. [ { "hireDate": null, "homePhoneNumber": null, "gender": null, "city": null, "mobileNumber": null, "idNumber": 123, "religion":…
0
votes
1 answer

No 'Access-Control-Allow-Origin' header is present in Rails API backend

I have a jsonapi-resources backend api in Rails. I am able to request data using curl as well as in Python. When I try using jQuery for the request I get the following error in the browser: XMLHttpRequest cannot load …
Adam12344
  • 1,043
  • 16
  • 33
0
votes
1 answer

JSON-API-Resources: How can I get the data related the specific object

How can I fetch the data related the specific object with JSON-API-Resources. Within controller, module Api module V1 class SubscriptionsController < Api::V1::ApiController def create @plan = Plan.find_by(id: plan_id_param) …
Toshi
  • 6,012
  • 8
  • 35
  • 58
0
votes
1 answer

Ember Data `include` Using JSONAPI Does Not Load Entire Payload

Using Ember-2.6 with Rails-4.2.7 backend JSONAPI-Resources-0.8.0.beta2 gem. I've noticed that sometimes when I try to include additional resources, they come back in my payload but don't end up in the Ember store properly. It then turns out that my…
Dan
  • 1,955
  • 17
  • 21