I have a has_many_polymorphs relationship that involves the following
class DigilearningModule < ActiveRecord::Base
:from => [:digilearning_titles, :lesson_categories,
:through => :digilearning_module_memberships,
:dependent => :destroy,
:uniq => true
class DigilearningModuleMembership < ActiveRecord::Base
belongs_to :member, :polymorphic => true
acts_as_list :scope => :digilearning_module
The classes listed in the from option have no further associations with
DigilearningModule or DigilearningModuleMembership, besides the ones
dynamically added by has_many_polymorphs.
As you can see, :uniq is set. This uniqueness is enforced on the
has_many relationship created from DigilearningModule to (eg)
DigilearningTitle, ie if i add a digilearning_title to a
digilearning_module multiple times, then the digilearning_module still
only has one digilearning_title. This is fine.
However, the uniqueness isn't enforced in the opposite direction. I can
add a digilearning_module to the same digilearning_title multiple times.
Before i go and start trying to monkey patch the has_many_polymorphs
code to add this uniqueness to the dynamically created has_many
associations it adds to its target classes, can anyone tell me
a) if this is normal
b) is there an easy fix?
thanks - max