-
-
Save markevich/7688924 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
| $ rails g model switchable_plan origin:references replacement:references 'switch_plan_fee:decimal{15,2}' | |
| # app/models/switchable_plan.rb | |
| class SwitchablePlan < ActiveRecord::Base | |
| belongs_to :origin | |
| belongs_to :replacement | |
| end | |
| # db/migrate/20131128082637_create_switchable_plans.rb | |
| class CreateSwitchablePlans < ActiveRecord::Migration | |
| def change | |
| create_table :switchable_plans do |t| | |
| t.references :origin, index: true | |
| t.references :replacement, index: true | |
| t.decimal :switch_plan_fee, precision: 15, scale: 2 | |
| t.timestamps | |
| end | |
| end | |
| end | |
| # spec/factories/switchable_plans.rb | |
| # Read about factories at https://github.com/thoughtbot/factory_girl | |
| FactoryGirl.define do | |
| factory :switchable_plan do | |
| origin nil | |
| replacement nil | |
| switch_plan_fee "9.99" | |
| end | |
| end | |
| # spec/models/switchable_plan_spec.rb | |
| require 'spec_helper' | |
| describe SwitchablePlan do | |
| pending "add some examples to (or delete) #{__FILE__}" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment