All Questions
Tagged with serialization ruby-on-rails
514 questions
0
votes
1
answer
289
views
Warning:: Passing the class as positional argument is deprecated and will be removed in Rails 7.2
serialize :reddoorz_property_ids, type: Object
DEPRECATION WARNING: Passing the class as positional argument is
deprecated and will be removed in Rails 7.2. Please pass the class as
a keyword argument:...
0
votes
1
answer
689
views
Data serialized in Rails 6 cannot be parsed in Rails 7
This seems insane to me. We are upgrading our app from Rails 6.1.7.7 to rails 7.1.3.4 and ruby 3.3.2 to 3.3.4.
In our items model, we have a simple serializer:
serialize :keywords, coder: JSON, type: ...
0
votes
0
answers
56
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
79
views
Updating a serialized field in Rails
I have a serialized attribute in my Rails model and am attempting to update it. The Block#preferences attribute was first generated through a migration as a text type. We use Postgresql 14.
# == ...
1
vote
1
answer
78
views
How to execute code "before_serialize"? or How can I sanitize attributes before they are serialized?
I am following this pattern to ensure all my attributes are normalized before they are saved:
class MyModel < ApplicationRecord
before_validation :normalize_attributes
def normalize_attributes
...
0
votes
1
answer
702
views
Rails/MySQL: better to use JSON column or serialized text for non-JSON use?
With my Rails 7.1.3 app, I have have a MySQL 8 db with a table users. Each user has many translations, and the translations belong to another table languages.
I'd like to cache the results of a query ...
0
votes
1
answer
148
views
How to serialize a postgres column in ruby on rails correctly
I'm trying to save to a column which has a datatype of 'string', within a postgres db using ruby on rails. Say I want to save an integer to this column. Is there any way to serialize the saved data in ...
0
votes
1
answer
60
views
Cannot use the helper method `current_user` in devise
I am building a simple todo app with nextjs and rails.
I am using devise for user authentication, but I can't use current_user.
Specifically, I am using JSON API Serializer to return user information ...
0
votes
1
answer
145
views
Ruby: How to pass parameters to oj_serializers
I'm using Oj Serializer: https://github.com/ElMassimo/oj_serializers.
I want to know how can I pass some variable(eg. CurrentCurrent) from controller to Serializer?
This for example controller:
class ...
0
votes
1
answer
297
views
Convert a returning Hash of a Model's method to a serializable_hash (for as_json)
My Modelclass has a method, that returns some calculated data in form of a Hash. In the Controller I want to use this data, but want to include only some parts of the Hash.
My first idea was, to use ...
0
votes
1
answer
86
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
715
views
Trying to implement Rails ActiveJob Serializer
I am trying to implement an ActiveJob Serializer in Rails 6.1.7 so that I can deliver email with the deliver_later method. Examples I see of this say that I should extend the class
ActiveJob::...
0
votes
0
answers
71
views
How do I render a nested model with a belongs_to association as an array in my API? I'm getting this: Error: Objects are not valid as a React child
I am trying to nest my models this way: a User has many Events, and an Event belongs to a client. I was able to get this working, my API is looking like this right now.
{
"id":1,
"...
2
votes
2
answers
153
views
Is it a good idea to serialize immutable data from an association?
Let's say we have a collection of products, each with their own specifics e.g. price.
We want to issue invoices that contain said products. Using a direct association from Invoice to Product via :...
0
votes
0
answers
105
views
JSON response with nested calculated key in ROR
I have a model and I need to group some of relations and make json response.
For example i have Models:
users: {
orders
...
}
orders: {
order_group
items
...
}
items: { ... }
order_groups:...