Saving habtm relationships and Rails 1.0


#1

I know there’s a problem saving has_and_belongs_to_many relationships w/
Rails 1.0 in that only the first association is saved
(http://dev.rubyonrails.org/ticket/3213).

What are people doing about this? I guess I could move to using the
trunk release, but I’m hesitant because that might introduce a bunch of
unknowns.

Is there a workaround? For example, a way to explicitly saves
assocations?

Thanks!

Jen


#2

I’ve been saving the associated object whenever I add something. This
is terribly inefficient, but I haven’t found a consensus on the
“right” way to do it.

Set up the staff object, and then…

default_entitlements = %w(this that the_other_thing)
staff.save
default_entitlements.each { |e|
staff.entitlements << Entitlement.find_by_code(e)
staff.save
}

Not great, but it works.