Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Having app to a working state. Entries work. Working on leaderboard a…
…ssociations
- Loading branch information
Rian Rainey
committed
Mar 20, 2013
1 parent
86570bd
commit 5c6fe66
Showing
28 changed files
with
2,473 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
$(document).ready(function(){ | ||
|
||
wysihtmlfive(); | ||
|
||
$("#entry_date_performed").datepicker({ | ||
dateFormat: 'yy-mm-dd'}); | ||
}); | ||
|
||
// Apply wysihtml5 to appropriate text areas | ||
function wysihtmlfive() { | ||
$('.wysihtml5').each(function(i, elem) { | ||
$(elem).wysihtml5(); | ||
}); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
class EntriesController < ApplicationController | ||
# GET /entries | ||
# GET /entries.json | ||
def index | ||
@entries = Entry.find_all_by_workout_id(params[:workout_id]) | ||
@workout = Workout.find(params[:workout_id]) | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @entries } | ||
end | ||
end | ||
|
||
# GET /entries/1 | ||
# GET /entries/1.json | ||
def show | ||
@entry = Entry.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @entry } | ||
end | ||
end | ||
|
||
# GET /entries/new | ||
# GET /entries/new.json | ||
def new | ||
@entry = Entry.new | ||
@workout = Workout.find(params[:workout_id]) | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @entry } | ||
end | ||
end | ||
|
||
# GET /entries/1/edit | ||
def edit | ||
#binding.pry | ||
@entry = Entry.find(params[:id]) | ||
@workout = Workout.find(params[:workout_id]) | ||
end | ||
|
||
# POST /entries | ||
# POST /entries.json | ||
def create | ||
@entry = Entry.new(params[:entry]) | ||
@entry.workout_id = params[:workout_id] | ||
@entry.user_id = current_user.id | ||
#@entry.date_performed(params[:entry][:date_performed]) | ||
|
||
respond_to do |format| | ||
if @entry.save | ||
format.html { redirect_to workout_entries_path(params[:workout_id]), notice: 'Entry was successfully created.' } | ||
format.json { render json: @entry, status: :created, location: @entry } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @entry.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /entries/1 | ||
# PUT /entries/1.json | ||
def update | ||
@entry = Entry.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @entry.update_attributes(params[:entry]) | ||
format.html { redirect_to workout_entries_path, notice: 'Entry was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @entry.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /entries/1 | ||
# DELETE /entries/1.json | ||
def destroy | ||
@entry = Entry.find(params[:id]) | ||
@entry.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to workout_entries_path, :notice => "Entry successfully deleted." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
class WorkoutsController < ApplicationController | ||
def index | ||
@workouts = Workout.all | ||
@workouts = Workout.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @workouts } | ||
end | ||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @workouts } | ||
end | ||
end | ||
|
||
def individual_workouts | ||
@entries = Entry.find_all_by_user_id(params[:user_id]) | ||
@workout = Workout.find_by_id(@entries.first.workout_id) | ||
|
||
respond_to do |format| | ||
format.html | ||
format.json { render json: @workouts } | ||
end | ||
end | ||
|
||
def leaderboard | ||
@entries = Entry.find_all_by_workout_id(params[:workout_id]).first(20) | ||
@workout = Workout.find_by_id(params[:workout_id]) | ||
|
||
respond_to do |format| | ||
format.html | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module EntriesHelper | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Entry < ActiveRecord::Base | ||
attr_accessible :id, :body, :user_id, :workout_id, :time, :rounds, :repetitions, :date_performed | ||
|
||
#accepts_nested_attributes_for :workout, :user | ||
|
||
belongs_to :workout | ||
belongs_to :user | ||
end |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
class Workout < ActiveRecord::Base | ||
attr_accessible :body, :title | ||
|
||
has_many :workouts | ||
has_many :users, :through => :workouts | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<%= form_for([@workout, @entry]) do |f| %> | ||
<h2 style="text-align: left">Workout Entry for <%= @workout.title %></h2> | ||
|
||
<div class="field"> | ||
<%= f.label :Rounds %> | ||
<%= f.text_field :rounds, :class => "input-medium" %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= f.label :Repetitions %> | ||
<%= f.text_field :repetitions, :class => "input-medium" %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= f.text_area :body, :placeholder => "Enter workout entry description here...", :class => "wysihtml5", :style => "width: 50%;", :rows => 5 %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= f.label :date_performed, "Date Performed" %> | ||
<%= f.text_field :date_performed, :class => "input-medium" %> | ||
</div> | ||
|
||
|
||
<div class="actions"> | ||
<%= f.submit :class => "btn btn-primary" %> | ||
</div> | ||
<% end %> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>Editing entry</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', workout_entries_path %> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<h1>Listing Workout Entries For <%= @workout.title %></h1> | ||
|
||
<table class="table table-striped"> | ||
<tr> | ||
<th>Date</th> | ||
<th>Description</th> | ||
<th>Rounds</th> | ||
<th>Repetitions</th> | ||
<th>Time</th> | ||
<th>Actions</th> | ||
</tr> | ||
|
||
<% @entries.each do |entry| %> | ||
<tr> | ||
<td><%= entry.date_performed.strftime("%m/%d/%y") %></td> | ||
<td><%= entry.body %></td> | ||
<td><%= entry.rounds %></td> | ||
<td><%= entry.repetitions %></td> | ||
<td><%= entry.time %></td> | ||
<td> | ||
<div class="btn-group"> | ||
<a href="#" class="btn dropdown-toggle" data-toggle="dropdown">Action<span class="caret"></span></a> | ||
<ul class="dropdown-menu"> | ||
<li><%= link_to 'Edit', edit_workout_entry_path(@workout, entry) %></li> | ||
<li><%= link_to 'Delete', workout_entry_path(@workout, entry), | ||
:confirm => "Are you sure?", :method => :delete %></li> | ||
</ul> | ||
</div> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
<%= link_to 'Add Entry', new_workout_entry_path %> | | ||
<%= link_to 'Back', workouts_path %> | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New entry</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', workout_entries_path(2) %> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
|
||
<%= link_to 'Edit', edit_entry_path(@entry) %> | | ||
<%= link_to 'Back' %> |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.