Created
October 2, 2015 15:25
-
-
Save psousa/a2cd8c4a646b7598cff5 to your computer and use it in GitHub Desktop.
experiment poly
This file contains hidden or 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
class Locatable < ActiveRecord::Base | |
belongs_to :locatable, :polymorphic=>true | |
belongs_to :location | |
end | |
class Location < ActiveRecord::Base | |
has_many :locatables, dependent: :destroy | |
end | |
class User < ActiveRecord::Base | |
has_one :locatable, :dependent => :destroy | |
has_one :location, :through => :locatable | |
accepts_nested_attributes_for :location, reject_if: proc { |attributes| attributes['google_place_id'].blank?} | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment