735 questions
0
votes
1
answer
303
views
Picking specific fields for an active model serializer association
In Active Model Serializers.. Let's say I have CompanySerializer and EmployeeSerializer. On CompanySerializer I have a field ceo where I want to render the association with EmployeeSerializer but ...
0
votes
0
answers
67
views
JBuilder and Rails 6.1
I am working on a POC for switching from active-model-serializer to jbuilder. I am very sad to see AMS being relegated to unsupported status. It's going to take forever to convert our 200+ serializers ...
0
votes
1
answer
266
views
.to_xml not working properly when using Active Model Serializer
I'm trying to render an xml response on my rails API using mime response.
the code is like this :
respond_to do |format| format.xml { render xml: @records.to_xml, status: :ok } format.json { render ...
0
votes
1
answer
81
views
(Ruby on Rails active_model_serializers) How to move nested hash up one level in a 2-level deep association with ActiveModel::Serializer?
I have the following ActiveRecord associations in Ruby on Rails:
class Driver
has_one :car
delegate :tires, to: :car
end
class Car
belongs_to :driver
has_many :tires
end
class Tire
...
0
votes
1
answer
95
views
ROR: Serializing output for multiple objects
I am learning rails, and using active_model_serializers gem.
I need to get the customized output in JSON from two different tables. Here is an example
car: id, name, color, size, shape, date...
...
1
vote
1
answer
245
views
Using models between an App and API app in Django Rest framework
I'm going to create API with Django Rest Framework for an existing Django project. I would like to use models of existing app (product/models.py) in 'API/models.py'.
Will that work smoothly as of ...
0
votes
1
answer
234
views
How do I use Active-record-serializer to compose custom JSON data
I have the following models and serializers. I want a situation that when I make a request to my List Controller index, I get Expected Json. Please see below:
# GET /lists
def index
@lists = ...
0
votes
1
answer
121
views
Ruby Active Model serializer custom serializer for same model
lets say I have a method as follows
def index
applications = Application.all
render json: applications, each_serializer: ApplicationIndexSerializer, ...
1
vote
1
answer
125
views
Problem with creating two objects with one controller action with ruby on rails
I am trying to send one post to a create in a controller and create two objects. For some reason the contoller only will create a company. I did a similair thing in sinatra and it worked. I know that ...
0
votes
1
answer
60
views
DFR Serializers vs. Forms, and handling of ImageField() as optional field, problem not working
My target is how to make ImageField() as optional in case user does not want to submit an image.
When I use django Forms, then the ImageField() will work fine where the field will be treated as ...
0
votes
1
answer
281
views
¿How to use a serializer for @record.all?
I have a Kit model with it's serializer:
class KitSerializer < ActiveModel::Serializer
attributes :id, :name, :description
has_many :products, only: [:id, :price]
end
I need to use this ...
0
votes
1
answer
848
views
ActiveModel::Serializers JSON API nested associations needs to include a value
I have an Rails 7 API and i'm using gem 'active_model_serializers', '~> 0.10.0' to make het fit in the json_api requirements, but i need to in the nested attributes of my items include the name, ...
0
votes
1
answer
39
views
How to render a part of fields embed model?
I want to render a part of embed model's fields .
I wrote bellow code.
But, I got a response include all embed model's fields.
class RacesController < ApplicationController
def index
render ...
1
vote
2
answers
262
views
Why does Rails rollback even though the model exists?
I am trying to find out why my update method is not working in my Rails API. It should update the bio field. I have my API hosted on Heroku and am using the Heroku logs to debug in production. I used ...
1
vote
2
answers
2k
views
Why rails_blob_url in the application and in the test works generates different links?
In ReviewsController serializers are used to display json. Like here:
render json: @reviews, each_serializer: ReviewSerializer, root: false
The serializer uses the following attribute :image. Like ...