bit closer on the tournament pairing algorithm (???) ActiveRecord associations are kind of a pain, btw.cat-town
parent
ec6d9d5146
commit
8ad33d18b7
@ -1,2 +1,6 @@
|
||||
class Mash < ActiveRecord::Base
|
||||
has_one :map_a, :class_name => 'Map'
|
||||
has_one :map_b, :class_name => 'Map'
|
||||
has_one :winner, :class_name => 'Map'
|
||||
has_one :requester
|
||||
end
|
||||
|
@ -0,0 +1,2 @@
|
||||
class Requester < ActiveRecord::Base
|
||||
end
|
@ -1,21 +1,21 @@
|
||||
class CreateMashes < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :mashes do |t|
|
||||
t.string :requester, :null => false
|
||||
t.integer :map_a, :null => false
|
||||
t.integer :map_b, :null => false
|
||||
t.integer :winner, :null => false
|
||||
t.integer :requester_id, :null => false
|
||||
t.integer :map_a_id, :null => false
|
||||
t.integer :map_b_id, :null => false
|
||||
t.integer :winner_id, :null => false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :mashes, [:winner]
|
||||
add_index :mashes, [:requester]
|
||||
add_index :mashes, [:winner_id]
|
||||
add_index :mashes, [:requester_id]
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :mashes, [:winner]
|
||||
remove_index :mashes, [:requester]
|
||||
remove_index :mashes, [:winner_id]
|
||||
remove_index :mashes, [:requester_id]
|
||||
drop_table :mashes
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,13 @@
|
||||
class CreateRequesters < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :requesters do |t|
|
||||
t.string :ip
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :requesters
|
||||
end
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
|
||||
one:
|
||||
ip: MyString
|
||||
|
||||
two:
|
||||
ip: MyString
|
@ -0,0 +1,13 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Requester do
|
||||
before(:each) do
|
||||
@valid_attributes = {
|
||||
:ip => "value for ip"
|
||||
}
|
||||
end
|
||||
|
||||
it "should create a new instance given valid attributes" do
|
||||
Requester.create!(@valid_attributes)
|
||||
end
|
||||
end
|
Loading…
Reference in new issue