Sha256: 1e14cfe85188effbf6898c6f216f4746d8646b24aa7ff669a070707b0dd15230

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

ActiveRecord::Base.establish_connection(
  :adapter  => 'sqlite3',
  :database => File.join(File.dirname(__FILE__), 'test.db')
)

class CreateSchema < ActiveRecord::Migration
  def self.up
    create_table :users, :force => true do |t|
      t.string  :first_name
      t.string  :last_name
      t.string  :email
      t.boolean :admin, :default => false
    end

    create_table :posts, :force => true do |t|
      t.string  :name  
      t.integer :author_id
    end
    
    create_table :business, :force => true do |t|
      t.string  :name  
      t.integer :owner_id
    end
  end
end

CreateSchema.suppress_messages { CreateSchema.migrate(:up) }

class User < ActiveRecord::Base
  validates_presence_of :first_name, :last_name, :email
  has_many :posts, :foreign_key => 'author_id'
end

class Business < ActiveRecord::Base
  validates_presence_of :name, :owner_id
  belongs_to :owner, :class_name => 'User'
end

class Post < ActiveRecord::Base
  validates_presence_of :name, :author_id
  belongs_to :author, :class_name => 'User'
end

Version data entries

8 entries across 8 versions & 5 rubygems

Version Path
gsterndale-warrant-0.2.0 test/rails_root/vendor/gems/thoughtbot-factory_girl-1.1.5/test/models.rb
gsterndale-warrant-0.3.0 test/rails_root/vendor/gems/thoughtbot-factory_girl-1.1.5/test/models.rb
handcrafted-factory_girl-1.1.14 test/models.rb
snowblink-factory_girl-1.1.5 test/models.rb
thoughtbot-factory_girl-1.1.4 test/models.rb
thoughtbot-factory_girl-1.1.5 test/models.rb
factory_girl-1.1.4 test/models.rb
factory_girl-1.1.5 test/models.rb