1
0
Fork 0

Dump of some setup but no feature adds

This commit is contained in:
Andrew Tomaka 2013-08-12 03:31:42 -04:00
parent 6e2414eb2e
commit 3978fec3d6
6 changed files with 53 additions and 1 deletions

7
app/models/lift.rb Normal file
View File

@ -0,0 +1,7 @@
class Lift < ActiveRecord::Base
belongs_to :workout
LIFTS = [:sqaut, :benchpress, :bentoverrow, :overheadpress,
:straightlegdeadlift, :uprightrow, :calfraise ]
validates_inclusion_of :lift, :in => Lift::LIFTS
end

View File

@ -1,4 +1,6 @@
class Workout < ActiveRecord::Base
has_many :lifts, dependent: :destroy
DAY_TYPES = [:heavy, :medium, :light ]
validates_date :date
validates_inclusion_of :day_type, :in => Workout::DAY_TYPES

View File

@ -0,0 +1,13 @@
class CreateLifts < ActiveRecord::Migration
def change
create_table :lifts do |t|
t.integer :parent_workout
t.string :lift_type
t.integer :sets
t.integer :repititions
t.text :comment
t.timestamps
end
end
end

View File

@ -0,0 +1,9 @@
class FixAssociationInLifts < ActiveRecord::Migration
def self.up
rename_column :lifts, :parent_workout, :workout_id
end
def self.down
rename_column :lifts, :workout_id, :parent_workout
end
end

View File

@ -11,7 +11,17 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20130811021123) do
ActiveRecord::Schema.define(version: 20130811190304) do
create_table "lifts", force: true do |t|
t.integer "workout_id"
t.string "lift_type"
t.integer "sets"
t.integer "repititions"
t.text "comment"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "workouts", force: true do |t|
t.date "date"

11
spec/factories/lifts.rb Normal file
View File

@ -0,0 +1,11 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :lift do
parent_workout 1
lift_type "MyString"
sets 1
repititions 1
comment "MyText"
end
end