ruby - RESTful way in rails to edit multiple DB entries at the same time -


to configure admin settings of app made admin controller , adminconfig model.

the admin controller have several categories (system,files,folders,…) , wanted separate them in adminconfig model setting category column in db. want in restful way , don't know how rails.

rails want edit each db row separately, want group them.

example: on files category have:

  • extension for
  • exif tags ignore
  • subfolder depth

each 1 separate entry in adminconfig model that:

  • name | value| category
  • extension | .jpg,.png,.avi | files
  • exif_tag | nil | files
  • subfolder_depth | 3 | files

(sorry table not working here)

so want show of them on page , when edit them want update them all. don't know how properly.

i can way or modify db 1 row == 1 category thats not how want achieve because it'll more difficult add more settings after.

if of settings belong same collection (e.g. several exiftag models) – can patch collection, that's not prohibited in rest (though you'll have define own action, there's no predefined 1 patching collection in rails).

patch [{id: 3, name: 'paul'}, {id: 4, name: 'dan'}] 

if settings belong 1 model – can patch model , pass data other models nested attributes, rails allows that.

patch {id: 1, hobbies_attributes: [{id: 1, name: 'hiking'}], house_attributes: { location_attributes: { city: 'vancouver' }} 

if non of these, want patch 2 different models unrelated each other - there's no "healthy" way in rest. can suggest go fancy frontend, send different requests different routes upon editing, updating different models; cleanest way.


Comments