Answer the question
In order to leave comments, you need to log in
How to convert for saving the data coming from the client side?
There is an API in the form of a rail application, and a client application in Angular.js.
Should I strive to achieve a state where data from the client comes 1 to 1, as needed, without the need for their mapping.
If not, then how to transform it so that it is DRY and generally beautiful?
Suppose a hash comes from the client containing the following data:
{
"name": "sample',
"tags": [
"non",
"adipisicing",
"deserunt",
"nulla",
"do",
"aute",
" enim"
]
}
On the client, you have to do something like:
AR::Transaction do
if record.save
tags.each do {|tag| record << tag.find_or_create_by(tag)}
end
end
Answer the question
In order to leave comments, you need to log in
Using, for example, Postgres and JSONB , you can save any hash and access the structures inside it as you like. Is this what your question is about?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question