vendredi 21 août 2015

Ruby on Rails Join Tables

I'm been battling with tutorials, documentation, and Q&A's here for a few days now, and I'm no further along. So I thought I'd post my first question.

I'm building a risk management application in Ruby on Rails. I have a Risk table, Controls table, and actions Table. A risk can have many controls, and each control can have many actions (outstanding tasks). Lastly, a control can be relevant to more than one risk. I'm trying to get all this to link together. So far I can add risks, add controls, and add actions. However I'd like to be able to render a partial at the bottom of each risk page that informs the user about what controls are assigned to that risk. They should also be able to add existing controls to the risk, or create new ones that are automatically associated with that risk.

Apologies if that all sounds a bit heavy.

I've created a join table for risks and controls, but I don't know how to make the risk_id and control_ids go in there when I press the 'Add Control' button (which doesn't exist yet by the way!). Any and all help will be appreciated!

I know you guys and gals are very bright, so I'm hoping theres an example you can throw me towards, if not, I'm more than happy to paste in any code you need to see!

Aucun commentaire:

Enregistrer un commentaire