Skip to content

Instantly share code, notes, and snippets.

@releu
Created April 26, 2012 06:05
Show Gist options
  • Save releu/2496437 to your computer and use it in GitHub Desktop.
Save releu/2496437 to your computer and use it in GitHub Desktop.
Inverse of doesn't work.
class Communication::Message < ActiveRecord::Base
belongs_to :conversation_for_proposal, {
:class_name => 'Communication::Conversation::ForProposal',
:foreign_key => :conversation_id,
:inverse_of => :messages_for_proposal
}
end
class Communication::Conversation::ForProposal < ActiveRecord::Base
has_many :messages_for_proposal, {
:class_name => 'Communication::Message',
:foreign_key => :conversation_id,
:inverse_of => :conversation_for_proposal
}
end
Communication::Message.new.build_conversation_for_proposal
.messages_for_proposal == []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment