Skip to content

Commit

Permalink
formatting for reading, fixed error with user_id, made helper to remo…
Browse files Browse the repository at this point in the history
…ve some logic out of the way
  • Loading branch information
Mirv committed May 31, 2017
1 parent 3fac989 commit c907166
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
18 changes: 12 additions & 6 deletions app/helpers/recipes_helper.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion app/views/recipes/_gravatar_section.html.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<%= link_to gravatar_for(user, size: 100), user_path(user) %>
<%= displayGravator?(user) %>
<h5> User name: <%= user.first_name %></h5>
24 changes: 16 additions & 8 deletions app/views/recipes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
<h3>Directions</h3>
<ol>
<%@recipe.directions.each do |direction| %>
<li><%= direction.step %></li><%end %>
<li><%= direction.step %></li>
<%end %>
</ol>
<%if @recipe.styles.any? %>
<p>Styles: <%= render @recipe.styles %></p>
Expand Down Expand Up @@ -65,13 +66,20 @@
<%= render partial: 'gravatar_section', locals: {user: @user} %>
<p></p><br>
<h3><br>
Reviews</h3><%if @recipe.reviews.any? %><%@recipe.reviews.each do |c| %>
<div class="well">
<div class="col-md-2 pull-right">
<strong>User: <%= c.user.username.downcase.capitalize %></strong>
</div>
<p><%= c.body %></p><i><small><%= c.updated_at.strftime("%m/%d/%Y") %></small></i> <%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 %>
</div><%end %><%else %>
Reviews</h3>
<%if @recipe.reviews.any? %>
<%@recipe.reviews.each do |c| %>
<div class="well">
<div class="col-md-2 pull-right">
<strong>User: <%= c.user.username.downcase.capitalize %></strong>
</div>
<p><%= c.body %></p><i><small><%= c.updated_at.strftime("%m/%d/%Y") %></small></i>
<%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 %>
</div>
<%end %>
<%else %>

<h5>Be the first to post a review!</h5><%end %>
<div class="form-group">
Expand Down

0 comments on commit c907166

Please sign in to comment.