File: environment.rb

package info (click to toggle)
ruby-pry-rails 0.3.9-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 320 kB
  • sloc: ruby: 844; makefile: 4
file content (81 lines) | stat: -rw-r--r-- 1,382 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require 'rails'
require 'rails/all'
require 'active_support/core_ext'

require 'pry-rails'

begin
  require 'mongoid'
rescue LoadError # Mongoid doesn't support Rails 3.0
end

# 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

if defined?(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
end