This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hey /r/rails!
Using Rails 3.2.13 and I've hit a major snag, hoping you guys could help.
Alright, so I need to make a model called LabTickets which has_many Tasks. Tasks has_many Equipment and belongs to User.
I need to be able to create the LabTicket independent of the Tasks- there can be LabTickets without tasks.
Ideally, I want the use case to be:
Create LabTask --> Add Task --> Select Equipment for Task --> Assign User to Task --> Save Task --> Automatically create a LabTicketTask association --> Automatically create TaskEquipment associations for each piece of Equipment associated with the Task --> Repeat as needed
Issue #1: When I add a Task, it should display a list of Equipment in the place the LabTicket was created. I need to be able to pick and choose from this list, then when the Task is saved, create a TaskEquipment record for each piece of Equipment selected, but I don't really know how to go about this.
I suspect that JavaScript might be useful for handling the cherry-picking of equipment and creation of TaskEquipment associations as they happen, but I am completely at a loss as to how JavaScript works on an object level (i.e. interacting with the database).
I also think that accepts_nested_attributes might work for assigning equipment, but as I'm not actually creating equipment when I add it to a Task (unlike a survey, where the questions are created when an answer is created, etc.), I'm not sure how.
Anyway, I really hope one of y'all can help me out.
Best,
Subreddit
Post Details
- Posted
- 10 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/rails/comme...