Another rails newbie here, trying to get started on some many to many :through structures (solid background in dB, php and asp). On the database and model side of things, everything is relatively clear. However, when it comes to the interactions on the web interface, I'm still not getting something.
I've seen a lot of good examples for _adding_ items that are linked to an existing item in another table, and others for creating multiple related items in one shot. However, what I haven't yet found is the means to link existing objects together via a join table. It will definitely be a join table rather an a has_many_and_belongs_to since there will be some additional data held in the join table.
The simplified use case looks something like this :
So I have people creating projects and consultants in their own independent tables (and models and controllers). Project planners need to assign consultants to projects and then assign timeblocks (managed in 1/2 day increments) which will be linked to both the consultant and the project.
Focussing on the consultant to project links I have the following (I still haven't worked out the tertiary join for the timeblocks to both missions and consultants):
class Consultant < ActiveRecord::Base
class Assignment < ActiveRecord::Base
class Mission < ActiveRecord::Base
has_many :timeblocks, :through => :consultants
The project planner will pull up a project page, and assign a consultant (potentially adding several) to the project. Under the project information, each assigned consultant will be displayed, and a calendar with selecting timeblocks as checkboxes so that I can pick the dates he'll be working on the project. Something like:
I was thinking of having a select list with an add button to build the association, but I haven't figured out how to build the necessary rhtml code to handle this. If I were working at a lower layer in php, I know exactly how I would accomplish this, but I'm still have a few difficulties in finding the appropriate Rails abstraction to express this.