Best design practice for form that creates data in multiple tables #317
willowlight
started this conversation in
General
Replies: 1 comment 1 reply
-
I'm assuming you're using Sequel? You have a few options (and probably more): Use the Open a transaction and create everything separately. You will have to handle your own validation errors here tho. DB.transaction do
article = Article.create(r.params["article"]) # Consider using .new and #set_fields instead
photo = Photo.create(r.params["photo"])
article.add_photo(photo)
# etc
end |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Just wondering if anyone has any advice on the best design practice for something along these lines:
Form is posted with article title, content, photo, etc that go into the articles table. But also with 'categories' and 'photos' that have their own table.
OR
I've always done #1 with my CMS/PHP work.
Thanks for any recommendations!
Beta Was this translation helpful? Give feedback.
All reactions