Last active
January 3, 2016 07:39
-
-
Save mrgenixus/8431332 to your computer and use it in GitHub Desktop.
Single Table Inheritance Prototype
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
| source 'https://rubygems.org' | |
| gem 'activerecord' | |
| gem 'pg' | |
| gem 'binding_of_caller' | |
| gem 'pry' |
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
| GEM | |
| remote: https://rubygems.org/ | |
| specs: | |
| activemodel (4.0.0) | |
| activesupport (= 4.0.0) | |
| builder (~> 3.1.0) | |
| activerecord (4.0.0) | |
| activemodel (= 4.0.0) | |
| activerecord-deprecated_finders (~> 1.0.2) | |
| activesupport (= 4.0.0) | |
| arel (~> 4.0.0) | |
| activerecord-deprecated_finders (1.0.3) | |
| activesupport (4.0.0) | |
| i18n (~> 0.6, >= 0.6.4) | |
| minitest (~> 4.2) | |
| multi_json (~> 1.3) | |
| thread_safe (~> 0.1) | |
| tzinfo (~> 0.3.37) | |
| arel (4.0.1) | |
| atomic (1.1.14) | |
| binding_of_caller (0.7.2) | |
| debug_inspector (>= 0.0.1) | |
| builder (3.1.4) | |
| coderay (1.0.9) | |
| debug_inspector (0.0.2) | |
| i18n (0.6.5) | |
| method_source (0.8.2) | |
| minitest (4.7.5) | |
| multi_json (1.8.2) | |
| pg (0.17.1) | |
| pry (0.9.12.4) | |
| coderay (~> 1.0) | |
| method_source (~> 0.8) | |
| slop (~> 3.4) | |
| slop (3.4.6) | |
| thread_safe (0.1.3) | |
| atomic | |
| tzinfo (0.3.38) | |
| PLATFORMS | |
| ruby | |
| DEPENDENCIES | |
| activerecord | |
| binding_of_caller | |
| pg | |
| pry |
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
| require 'rubygems' | |
| require 'bundler/setup' | |
| require 'active_record' | |
| require 'pry' | |
| ActiveRecord::Base.establish_connection( | |
| adapter: 'postgresql', | |
| host: 'localhost', | |
| database: 'sti_development' | |
| ) | |
| ActiveRecord::Schema.define do | |
| if !table_exists? :products | |
| create_table :products do |t| | |
| t.string :name | |
| t.string :type | |
| end | |
| end | |
| if !table_exists? :values | |
| create_table :values do |t| | |
| t.float :market | |
| t.float :buy | |
| t.float :sell | |
| t.string :system | |
| end | |
| end | |
| end | |
| class Product < ActiveRecord::Base | |
| belongs_to :value | |
| end | |
| class Value < ActiveRecord::Base | |
| end | |
| class AddValueIdToProductsMigration < ActiveRecord::Migration | |
| def up | |
| add_column :products, :value_id, :integer | |
| end | |
| end | |
| AddValueIdToProductsMigration.run(AddValueIdToProductsMigration) if ! Product.column_names.include? :value_id | |
| class Tech1 < Product; end; | |
| class Tech2 < Product; end; | |
| class Tech3 < Product; end; | |
| class Mineral < Product; end; | |
| class Tech2Component < Product; end; | |
| class Tech2CapitalComponent < Product; end; | |
| binding.pry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment