Created
May 4, 2016 18:41
-
-
Save hutch78/9b112926df4b56cdac717ab58c8df5da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Property model | |
class Property < ActiveRecord::Base | |
has_and_belongs_to_many :contacts, -> { uniq } | |
end | |
# Contact model | |
class Contact < ActiveRecord::Base | |
has_and_belongs_to_many :properties, -> { uniq } | |
end | |
# join table is created like so | |
create_join_table :properties, :contacts do |t| | |
t.index [:property_id, :contact_id] | |
end | |
# how i would like to delete them | |
@property.contacts.delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment