diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fc23f45..39f68a2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -11,7 +11,10 @@ def full_title(page_title = '') end end - + def user?(user) + return true unless user.nil? + return false + end def gravatar_for(user, options = { size: 80}) diff --git a/app/helpers/recipes_helper.rb b/app/helpers/recipes_helper.rb index 74d231b..0de952e 100644 --- a/app/helpers/recipes_helper.rb +++ b/app/helpers/recipes_helper.rb @@ -7,9 +7,8 @@ def is_owner? end end - def displayGravator?(user) - link_to gravatar_for(user, size: 100), user_path(user) unless user.nil? - + def user?(user) + return true 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 6913a0e..50f3fd2 100644 --- a/app/views/recipes/_gravatar_section.html.erb +++ b/app/views/recipes/_gravatar_section.html.erb @@ -1,2 +1,4 @@ -<%= displayGravator?(user) %> -
User name: <%= user.first_name %>
+

+ <%= link_to gravatar_for(user, size: 100), user_path(user) %> +

User name: <%= user.first_name %>
+

diff --git a/app/views/recipes/show.html.erb b/app/views/recipes/show.html.erb index 5fd735b..b6a1dd6 100644 --- a/app/views/recipes/show.html.erb +++ b/app/views/recipes/show.html.erb @@ -21,79 +21,84 @@

Ingredients

Directions

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

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

- <%end %> - <%if @recipe.feeds.any? %> + <% end %> + <% if @recipe.feeds.any? %>

Feeds: <%= render @recipe.feeds %>

- <%end %> - <%if @recipe.preptimes.any? %> + <% end %> + <% if @recipe.preptimes.any? %>

Preptime: <%= render @recipe.preptimes %>

- <%end %> + <% end %>

Notes:

<%= simple_format(@recipe.description) %>
<%= link_to like_recipe_path(@recipe, like: true), :method => :post do %>   <%= @recipe.thumbs_up_total %> - <%end %>      + <% end %>      <%= link_to like_recipe_path(@recipe, like: false), method: :post do %>   <%= @recipe.thumbs_down_total %> - <%end %> + <% end %>
- <%if logged_in? and is_owner? %> + <% if logged_in? and is_owner? %> <%= link_to "Edit this Recipe", edit_recipe_path(@recipe), class: "btn btn-success pull-right edit" %> - <%end %> + <% end %> - <%if logged_in? and (is_owner?) %> + <% if logged_in? and (is_owner?) %> <%= link_to "[Delete Recipe]", @recipe, method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-danger pull-right delete"%> - <%end %> + <% end %>
Share this! <%= social_share_button_tag(@recipe.name) %>
- <%= render partial: 'gravatar_section', locals: {user: @user} %> -


-


- Reviews

- <%if @recipe.reviews.any? %> - <%@recipe.reviews.each do |c| %> + <% if user?(@user) %> + <%= render partial: 'gravatar_section', locals: {user: @user} %> + <% end %> + +

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 %> +

<%= c.body %>

+ <%= c.updated_at.strftime("%m/%d/%Y") %> + <% if is_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 %> + <% end %>
- <%end %> + <% end %> <%else %> - -
Be the first to post a review!
<%end %> +
Be the first to post a review!
+ <% end %>
- <%= form_tag(review_recipe_path, :method=>'post') do %><%= text_area_tag "body", nil, size:"5x5", class:"form-control" %><%= submit_tag "Submit Review", class: "btn btn-primary" %>
+ <%= form_tag(review_recipe_path, :method=>'post') do %><%= text_area_tag "body", nil, size:"5x5", class:"form-control" %><%= submit_tag "Submit Review", class: "btn btn-primary" %> +

-
<%end %> + <% end %> +

You may also like:


- <%@random_recipe.each do |recipe| %> -
-
- <%=image_tag recipe.picture %> -
<%= link_to recipe.name, recipe %><%= truncate(recipe.description, length: 150)%><%=link_to 'click to see more', recipe_path(recipe)%> -
<%end %> + <% @random_recipe.each do |recipe| %> +
+
+ <%=image_tag recipe.picture %> +
<%= link_to recipe.name, recipe %><%= truncate(recipe.description, length: 150)%><%=link_to 'click to see more', recipe_path(recipe) %> +
+ <% end %>