Skip to content

Commit

Permalink
adding devise filters to controllers, accidentally changed some on th…
Browse files Browse the repository at this point in the history
…e master >.<
  • Loading branch information
jatwell93 committed Jun 5, 2017
1 parent 1bcc1ab commit 0d1fef7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class DashboardController < ApplicationController
before_action :authenticate_user!
def index
@athletes = User.paginate(:page => params[:page])
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class UsersController < ApplicationController
include ExercisesHelper
before_action :require_same_user, only: [:edit, :update]
before_action :set_user, only: [:show, :edit, :update, :destroy, :finish_signup]

Expand Down
7 changes: 7 additions & 0 deletions app/helpers/exercises_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module ExercisesHelper

def exercise_owner?
owner_check(@exercises.user_id)
end

end
4 changes: 3 additions & 1 deletion app/views/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@
No Workouts yet
</div>
<%end%>
<%= link_to "New Workout", new_user_exercise_path(current_user), class: "btn btn-primary link" %>
<% if logged_in? and exercise_owner? %>
<%= link_to "New Workout", new_user_exercise_path(current_user), class: "btn btn-primary link" %>
<% end %>
<%= content_tag :div, "", id: 'chart', data: {workouts: @exercises}, class: "chart" %>
</div>
<hr>
Expand Down

0 comments on commit 0d1fef7

Please sign in to comment.