Skip to content

Instantly share code, notes, and snippets.

@MichaelDrogalis
Created November 23, 2011 20:47
Show Gist options
  • Save MichaelDrogalis/1389857 to your computer and use it in GitHub Desktop.
Save MichaelDrogalis/1389857 to your computer and use it in GitHub Desktop.
class WorkoutsController < ApplicationController
2 before_filter :authenticate_user!
3
4 def index
5 @writable = true
6 @period = TrainingPeriod.new current_user.id, DateTime.now.in_time_zone.midnight
7 end
8
9 def new
10 @workout = Workout.new
11 end
12
13 def new_with_date
14 @workout = Workout.new
15 @workout_date = TrainingPeriod.parse_date params[:date]
16 render :action => "new"
17 end
18
19 def create
20 date = params[:workout]["when(2i)"] + "-" + params[:workout]["when(3i)"] + "-" + params[:workout]["when(1i)"]
21
22 workout = Workout.create params[:workout]
23 workout.user_id = current_user.id
24 workout.save!
25
26 redirect_to :action => "show_week", :startdate => date
27 end
28
29 def show_week
30 @writable = true
31 @period = TrainingPeriod.new current_user.id, TrainingPeriod.parse_date(params[:startdate])
32 end
33 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment