hi everybody,
i am quite new to ror and tried to find any relevant information on
this topic. but none of the guides i found really helped me so far.
so i hope there is someone on the list with a solution.
i have to models (artist, group) connected by
has_and_belongs_to_many. in the join table i defined an optional
field (instrument).
an artist can belong to many different groups and a group can have
different artists. and an artist can play different instruments
within the group. so i thought i add the instrument_id as an optional
field to the join table and add multiple records for each instrument
(i have a working solution in php, but wanna upgrade to ror now).
i thought i could do it with:
@artist = Artist.new
@group = Group.find(params[:groups][:id])
for ins in params[:instruments]
@artist
@artist.groups.push_with_attributes(@group, {''instrument_id''
=> ins})
end
but the "push_with_attributes" method adds two times the same record
( the second one. i haven''t checked it, but i suppose it will always
use the last added values)
any ideas on how to change the functions behaviour from adding
multiple times the same record, to adding different records with the
original value?
as this is none of the documented functions i do not really know
where to check the source-code. any help is appreciated a lot ;)
max