From c90716606b3556c1d2cc17c17c4931df41dfc911 Mon Sep 17 00:00:00 2001 From: Mirv Date: Wed, 31 May 2017 19:24:51 +0000 Subject: [PATCH] formatting for reading, fixed error with user_id, made helper to remove some logic out of the way --- app/helpers/recipes_helper.rb | 18 ++++++++++----- app/views/recipes/_gravatar_section.html.erb | 2 +- app/views/recipes/show.html.erb | 24 +++++++++++++------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/app/helpers/recipes_helper.rb b/app/helpers/recipes_helper.rb index 7ef181b..74d231b 100644 --- a/app/helpers/recipes_helper.rb +++ b/app/helpers/recipes_helper.rb @@ -1,9 +1,15 @@ module RecipesHelper - def is_owner? - if current_user.id == @recipe.user_id then - return true - else - return false - end + def is_owner? + if current_user.id == @recipe.user_id then + return true + else + return false end + end + + def displayGravator?(user) + link_to gravatar_for(user, size: 100), user_path(user) unless user.nil? + + end + end \ No newline at end of file diff --git a/app/views/recipes/_gravatar_section.html.erb b/app/views/recipes/_gravatar_section.html.erb index 4971b94..6913a0e 100644 --- a/app/views/recipes/_gravatar_section.html.erb +++ b/app/views/recipes/_gravatar_section.html.erb @@ -1,2 +1,2 @@ -<%= link_to gravatar_for(user, size: 100), user_path(user) %> +<%= displayGravator?(user) %>
User name: <%= user.first_name %>
diff --git a/app/views/recipes/show.html.erb b/app/views/recipes/show.html.erb index 75a5d55..5fd735b 100644 --- a/app/views/recipes/show.html.erb +++ b/app/views/recipes/show.html.erb @@ -27,7 +27,8 @@

Directions

    <%@recipe.directions.each do |direction| %> -
  1. <%= direction.step %>
  2. <%end %> +
  3. <%= direction.step %>
  4. + <%end %>
<%if @recipe.styles.any? %>

Styles: <%= render @recipe.styles %>

@@ -65,13 +66,20 @@ <%= render partial: 'gravatar_section', locals: {user: @user} %>



- Reviews

<%if @recipe.reviews.any? %><%@recipe.reviews.each do |c| %> -
-
- User: <%= c.user.username.downcase.capitalize %> -
-

<%= c.body %>

<%= c.updated_at.strftime("%m/%d/%Y") %> <%if c.user == current_user %> <%= 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 %> -
<%end %><%else %> + Reviews + <%if @recipe.reviews.any? %> + <%@recipe.reviews.each do |c| %> +
+
+ User: <%= c.user.username.downcase.capitalize %> +
+

<%= c.body %>

<%= c.updated_at.strftime("%m/%d/%Y") %> + <%if c.user == current_user %> + <%= 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 %> +
+ <%end %> + <%else %>
Be the first to post a review!
<%end %>