diff --git a/Pearlception/app/models/oyster.rb b/Pearlception/app/models/oyster.rb index 7600c3a..0a7cdb6 100644 --- a/Pearlception/app/models/oyster.rb +++ b/Pearlception/app/models/oyster.rb @@ -1,4 +1,6 @@ -class Oyster < ActiveRecord::Base - establish_connection("stats") - +class Oyster < ApplicationRecord + belongs_to :run + Oyster.establish_connection(:"stats_#{Rails.env}") + + end diff --git a/Pearlception/app/models/run.rb b/Pearlception/app/models/run.rb new file mode 100644 index 0000000..18c81f6 --- /dev/null +++ b/Pearlception/app/models/run.rb @@ -0,0 +1,4 @@ +class Run < ApplicationRecord + has_many :oysters + establish_connection(:"stats_#{Rails.env}") +end diff --git a/Pearlception/config/database.yml b/Pearlception/config/database.yml index 835347d..6d149be 100644 --- a/Pearlception/config/database.yml +++ b/Pearlception/config/database.yml @@ -17,15 +17,19 @@ default: &default password: terps socket: /var/run/mysqld/mysqld.sock -stats: +stats_development: &stats adapter: mysql2 encoding: utf8 pool: 5 - username: <%= ENV['DB_USER'] %> + username: ivauser password: <%= ENV['DB_PASS'] %> host: taylors.c02zesysnssi.us-west-2.rds.amazonaws.com port: 3306 - database: taylors + database: main + + +stats_test: + <<: *stats development: <<: *default diff --git a/Pearlception/test/models/oyster_test.rb b/Pearlception/test/models/oyster_test.rb new file mode 100644 index 0000000..c29d260 --- /dev/null +++ b/Pearlception/test/models/oyster_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class OysterTest < ActiveSupport::TestCase + test "the_truth" do + f = Oyster.first + puts f.inspect + assert true + end +end