I’ve read through my RoR books and I can’t seem to find the solution.
This is a pretty basic, easy, and practical application for RoR. If you
guys know of any resources on the net to answer these questions let me
Basically, I have a many-to-many relationship that I want to add records
to. I use something like this to add records in the A_B table:
This takes the ones that already exist and establishes a relationship
between A and B.
What if I want to take ones that don’t exist in params[:clubs] and have
those added to Club table? Is there any shortcut operator for doing that
AND also does the << operation at the same time? What if I want to add
another record for a particular instance of A even though there are
already records in the database. I tried using “<<” and got error, since
it cannot add an entry that already exists. Is there any operation that
handles this situation?
In a one-to-many relationship, where I have a_id column in my b table,
how do I take many records that have to go in b and get ActiveRecord to
either create new entries OR update the ones that exist.
Do I have to find_all and delete all of them and then reenter them into
the database. It seems like there would be smarter mechanism in Ruby for