Rails - Best-Practice: How to create dependent has_one relations
Similar to the question above. I have a record that I want to have one (polymorphic relationship), but a "default" dependent object isn't goo enough? The closest I can find is Is it possible to pass params from to a before_create in a model?, but since it has very low upvotes and is clunky I'm not sure it is the "right" solution.
class A < ActiveRecord::Base
has_one :b, :as=>:foo, :dependent=>:destroy
accepts_nested_attributes_for :b
end
class B < ActiveRecord::Base
belongs_to :foo, polymorphic: true
end