Skip to content

Instantly share code, notes, and snippets.

@lilithlavender
Last active December 28, 2015 22:09
Show Gist options
  • Select an option

  • Save lilithlavender/7569216 to your computer and use it in GitHub Desktop.

Select an option

Save lilithlavender/7569216 to your computer and use it in GitHub Desktop.
class Franchisee < ActiveRecord::Base
belongs_to :user
has_many :phone_numbers, as: :phoneable, dependent: :destroy
accepts_nested_attributes_for :phone_numbers, allow_destroy: true
validates :region_code, presence: true
end
class PhoneNumber < ActiveRecord::Base
belongs_to :phoneable, :polymorphic => true
validates :phone_number, presence: true
end
class User < ActiveRecord::Base
has_one :franchisee, dependent: :destroy
accepts_nested_attributes_for :franchisee
validates :first_name, presence: true
validates :last_name, presence: true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment