All threads / How do I assign multiple user_id's to one work order record
Ask A Question


You’re not receiving notifications from this thread.

How do I assign multiple user_id's to one work order record

Austin Klenk asked in Rails

i got a question ive been scratching my head for a few days on a solution to a problem. I currently have work order that we assign a single user to and im trying to figure out the best way to assign multiple users to a single work order so if multiple people work on one work order at the same time they will have their own time card as well. I currently have a belongs_to association on the order model and on the user model I have has_many :orders. On my form i have a collection select that accepts multiple: true and in the database (pg) under the order table i have a user_id: integer column. Is there any additional steps to make this work? also in the order controller, i have user_id: [] under the order_params to accept the nested array or selected users in the form. Any pointers would be greatly appreciated.

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 66,029+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.