Created
November 5, 2015 11:23
-
-
Save risen/b5a76d0929379303af30 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
require 'bundler' | |
Bundler.require | |
class Product < ActiveRecord::Base | |
actable | |
belongs_to :pen_case | |
end | |
class Pen < ActiveRecord::Base | |
acts_as :product | |
end | |
class PenCase < ActiveRecord::Base | |
acts_as :product | |
has_many :products | |
end | |
class CreateProducts < ActiveRecord::Migration | |
def change | |
create_table :products do |t| | |
t.actable | |
t.references :pen_case | |
t.string :name | |
t.decimal :price | |
end | |
end | |
end | |
class CreatePens < ActiveRecord::Migration | |
def change | |
create_table :pens do |t| | |
t.string :color | |
end | |
end | |
end | |
class CreatePenCases < ActiveRecord::Migration | |
def change | |
create_table :pen_cases do |t| | |
t.integer :capacity | |
end | |
end | |
end | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db.sqlite3') | |
ActiveRecord::Base.logger = Logger.new(STDERR) | |
ActiveRecord::Base.logger.level = Logger::INFO | |
ActiveRecord::Migration.verbose = true | |
ActiveRecord::Migration.descendants.each { |m| m.migrate(:up) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment