JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Dealing with strong parameters with nested hash in JR
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 2.3k
- Fork
- 546
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Not sure how to deal with this strong parameters issue in a JSONAPI::ResourceController.
I have a simple User model with settings field that is stored in Postgres as a jsonb field type. The resource looks like this:
class API::V1::UserResource < JSONAPI::Resource
key_type :uuid
attributes :username, :email, :first_name, :last_name, :roles
attribute :settings
def roles
@model.roles.to_a
end
end
This serializes out just fine, but trying to PATCH with something like the body below:
{
"data": {
"id": "776c526a-6b5f-4839-998e-591d3043645d",
"type": "users",
"attributes": {
"settings": {
"color": "blue"
}
}
}
}
If config.raise_if_parameters_not_allowed = false then I get this stored in the database:
"--- !ruby/object:ActionController::Parameters\nparameters: !ruby/hash:ActiveSupport::HashWithIndifferentAccess\n color: blue\npermitted: false\n"
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Parti dalla gestione degli strong parameter di JSONAPI::ResourceController e riproduci la richiesta PATCH per il campo jsonb settings della risorsa User. La correzione è completa quando le impostazioni annidate vengono memorizzate come dati JSON anziché come un oggetto ActionController::Parameters serializzato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- postgresql, rails, ruby
- Ambito
- api, backend, database
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100