Created
November 23, 2011 20:47
-
-
Save MichaelDrogalis/1389857 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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