From 244a8da37ad0f014361ae6673f85ed37adc37771 Mon Sep 17 00:00:00 2001 From: Mirv Date: Wed, 31 May 2017 22:45:36 +0000 Subject: [PATCH] helper scope fix #2 --- app/helpers/recipes_helper.rb | 2 +- app/helpers/workouts_helper.rb | 3 +-- app/views/recipes/show.html.erb | 4 ++-- app/views/workouts/show.html.erb | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/helpers/recipes_helper.rb b/app/helpers/recipes_helper.rb index 8a56d06..61e5e43 100644 --- a/app/helpers/recipes_helper.rb +++ b/app/helpers/recipes_helper.rb @@ -1,6 +1,6 @@ module RecipesHelper - def owner? + def recipe_owner? owner_check(@recipe.user_id) end diff --git a/app/helpers/workouts_helper.rb b/app/helpers/workouts_helper.rb index 2a4866a..b919788 100644 --- a/app/helpers/workouts_helper.rb +++ b/app/helpers/workouts_helper.rb @@ -1,7 +1,6 @@ module WorkoutsHelper - def owner? - # owner_check(@recipe.user_id) + def workout_owner? owner_check(@workout.user_id) end diff --git a/app/views/recipes/show.html.erb b/app/views/recipes/show.html.erb index 9b365b7..5548eda 100644 --- a/app/views/recipes/show.html.erb +++ b/app/views/recipes/show.html.erb @@ -50,7 +50,7 @@ <% end %> - <% if logged_in? and owner? %> + <% if logged_in? and recipe_owner? %> <%= link_to "Edit this Recipe", edit_recipe_path(@recipe), class: "btn btn-success pull-right edit" %> <%= link_to "[Delete Recipe]", @recipe, method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger pull-right delete"%> <% end %> @@ -73,7 +73,7 @@

<%= c.body %>

<%= c.updated_at.strftime("%m/%d/%Y") %> - <% if owner? %> + <% if recipe_owner? %> <%= link_to "Delete", review_recipe_path(:revid => c.id), class:"btn btn-danger btn-small pull-right", method: :delete, data: { confirm: "Are you sure you want to delete this review?" } %> <% end %> diff --git a/app/views/workouts/show.html.erb b/app/views/workouts/show.html.erb index bddb275..e546983 100644 --- a/app/views/workouts/show.html.erb +++ b/app/views/workouts/show.html.erb @@ -55,7 +55,7 @@
Share this workout!<%= social_share_button_tag( "#{@workout.user.username}'s Workout Plan") %>
- <% if logged_in? and (owner? || current_user.admin?) %> + <% if logged_in? and (workout_owner? || current_user.admin?) %> <%= link_to "Edit this Workout", edit_workout_path(@workout), class: "btn btn-success pull-right edit" %>    <%= link_to "[Delete Workout]", @workout, method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger pull-right delete"%> @@ -81,7 +81,7 @@

<%= c.body %>

<%= c.updated_at.strftime("%m/%d/%Y") %> - <% if owner_check(c.user) %> + <% if workout_owner? %> <%= link_to "Delete Review", review_workout_path(:revid => c.id), class:"btn btn-danger btn-small pull-right", method: :delete, data: { confirm: "Are you sure you want to delete this review?" } %> <% end %>