Given the following:
Foo has_many :bars, :through => :baz
and
Foo accepts_nested_attributes_for :bar
I want to do a find_or_create_by_name
when I add a new :bar
, but I don't know where I can have some sort of before_add
functionality.
The background of this question is Bar validates_uniqueness_of :name
, which gives errors when I try to create a new Foo
that is using an existing Bar
.