Permalink
Browse files

added position to frame and initialized it

  • Loading branch information...
1 parent aead1d8 commit c3517fea2a17db9e70c1e78bedcf67069732b646 @tritchie committed Oct 1, 2011
Showing with 14 additions and 4 deletions.
  1. +3 −3 app/controllers/games_controller.rb
  2. +9 −0 db/migrate/20111001204517_add_position_to_frame.rb
  3. +2 −1 db/schema.rb
@@ -39,10 +39,10 @@ def create
respond_to do |format|
if @game.save
- @game.current_frame = @game.frames.create(:ball1 => 0, :ball2 => 0).id
- 9.times do
- @game.frames.create(:ball1 => 0, :ball2 => 0)
+ (1..10).each do |position|
+ @game.frames.create(:ball1 => 0, :ball2 => 0, :position => position)
end
+ @game.active_frame = @game.current_frame = @game.frames.first.id
if @game.save
format.html { redirect_to(@game, :notice => 'Game was successfully created.') }
format.xml { render :xml => @game, :status => :created, :location => @game }
@@ -0,0 +1,9 @@
+class AddPositionToFrame < ActiveRecord::Migration
+ def self.up
+ add_column :frames, :position, :integer
+ end
+
+ def self.down
+ remove_column :frames, :position
+ end
+end
View
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20111001181112) do
+ActiveRecord::Schema.define(:version => 20111001204517) do
create_table "frames", :force => true do |t|
t.integer "ball1"
@@ -19,6 +19,7 @@
t.datetime "updated_at"
t.integer "total"
t.integer "game_id"
+ t.integer "position"
end
create_table "games", :force => true do |t|

0 comments on commit c3517fe

Please sign in to comment.