Sha256: 84efcaf03cfab3f034ee14fa6b8bcd5bed8667d66018cbaf9d4356558e3df615
Contents?: true
Size: 1.33 KB
Versions: 5
Compression:
Stored size: 1.33 KB
Contents
require 'rails' require 'rails/all' require 'active_support/core_ext' require 'pry-rails' # Initialize our test app class TestApp < Rails::Application config.active_support.deprecation = :log config.eager_load = false config.secret_token = 'a' * 100 config.root = File.expand_path('../..', __FILE__) end TestApp.initialize! # Create in-memory database ActiveRecord::Migration.verbose = false ActiveRecord::Schema.define do create_table :pokemons do |t| t.string :name t.binary :caught t.string :species t.string :abilities end create_table :hackers do |t| t.integer :social_ability end create_table :beers do |t| t.string :name t.string :type t.integer :rating t.integer :ibu t.integer :abv end end # Define models class Beer < ActiveRecord::Base belongs_to :hacker end class Hacker < ActiveRecord::Base has_many :pokemons has_many :beers end class Pokemon < ActiveRecord::Base belongs_to :hacker has_many :beers, :through => :hacker end begin require 'mongoid' class Artist include Mongoid::Document field :name, :type => String embeds_one :beer embeds_many :instruments end class Instrument include Mongoid::Document field :name, :type => String embedded_in :artist end rescue LoadError # Mongoid doesn't support Rails 3.0 end
Version data entries
5 entries across 5 versions & 2 rubygems