-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Associations
-
None
-
Minor Change
Relations are set after defaults, so you can't use any relation method as default value.
class Band include Mongoid::Document has_many :songs field :name end class Song include Mongoid::Document belongs_to :band field :band_name, default: -> { band.name } field :name end band = Band.create(name: "Molejo") song = band.songs.create(name: "Cilada")
It may be very useful, e.g.: denormalization.
- is related to
-
MONGOID-5288 Document that _id default value override using a Proc requires pre_processed: true option
- Closed