Skip to content

Commit

Permalink
Helper method to add popular item flag for menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
scrabill committed Dec 23, 2019
1 parent 4528409 commit 3cd4586
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/helpers/menu_items_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
module MenuItemsHelper

def is_popular?(item)
if item.id == Order.most_popular.id
content_tag(:span, 'Popular Item!', class: "tag is-primary is-light is-rounded is-normal")
end
end
end
2 changes: 1 addition & 1 deletion app/views/menu_items/index.html.erb
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
<ul>
<% @items.sort! { |a, b| a.name <=> b.name }.each do |item| %>
<li>
<%= link_to item.name, menu_item_path(item) %> - <%= link_to "Edit", edit_menu_item_path(item) %>
<%= link_to item.name, menu_item_path(item) %> <%= is_popular?(item) %> - <%= link_to "Edit", edit_menu_item_path(item) %>
</li>
<% end %>
</ul>

0 comments on commit 3cd4586

Please sign in to comment.