Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Operator association<< works differently from ActiveRecord and is not documented #466

aledalgrande opened this Issue Oct 17, 2012 · 1 comment


None yet
2 participants

aledalgrande commented Oct 17, 2012


I have a model like this:

class Proposal < Document
  # ...
  key :media_channel_ids, Array
  many :media_channels, :in => :media_channel_ids
  # ...

And this doesn't work as expected:

# ...
proposal.media_channels << MediaChannel.create(hash)

In ActiveRecord when you do that, the relationship would be saved automatically. As here the relationship is managed differently, the IDs are stored in the Proposal object, but the proposal instance itself is not saved automatically after the IDs are added to the media_channels array.

This isn't documented anywhere, so I wanted just to check if 1) this is the expected behaviour and 2) it can be documented on the official website.



smtlaissezfaire commented Nov 17, 2014

Depends. If you have MediaChannel.create(hash) where the hash includes { :proposal => proposal } this will work correctly. Also note that you are assuming proposal is already saved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment