Skip to content

Instantly share code, notes, and snippets.

@psousa
Created October 2, 2015 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psousa/a2cd8c4a646b7598cff5 to your computer and use it in GitHub Desktop.
Save psousa/a2cd8c4a646b7598cff5 to your computer and use it in GitHub Desktop.
experiment poly
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