Created
September 25, 2013 21:01
-
-
Save steveburkett/6705979 to your computer and use it in GitHub Desktop.
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
Given: | |
Organization | |
has_one :plan, dependent: :destroy, inverse_of: :organization | |
validates_presence_of :name, :plan | |
Plan | |
belongs_to :organization, inverse_of: :plan | |
validates :organization, :type, presence: true | |
class Plan < ActiveRecord::Base { | |
:id => :integer, | |
:organization_id => :integer, | |
:type => :string ... | |
class FreePlan < Plan | |
end | |
I need: | |
(1) that when i create a organization, it creates and associates itself w/ a default FreePlan. This is saved when an org is saved (& once a plan is set, dont accidentally override it). How to do this? | |
(2) need to make sure that the blueprint builds a org w/ the FreePlan | |
Organization.blueprint do | |
name { "Test Corp" } | |
end | |
#Organization.make.plan.class == "FreePlan" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment