updated recipe index
This commit is contained in:
parent
aed9ac9fd5
commit
10bec318a7
@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
def ensure_valid_user
|
||||
if current_user.nil?
|
||||
unless current_user?
|
||||
flash[:warning] = "You must login"
|
||||
redirect_to login_path
|
||||
end
|
||||
@ -22,6 +22,11 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
helper_method :current_user
|
||||
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
end
|
||||
helper_method :current_user?
|
||||
|
||||
def set_current_user(user)
|
||||
if user
|
||||
session[:user_id] = user.id
|
||||
|
@ -14,7 +14,9 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<% if current_user? %>
|
||||
<th colspan="2"></th>
|
||||
<% end %>
|
||||
<th>Yields</th>
|
||||
<th>Time</th>
|
||||
<th>Created</th>
|
||||
@ -26,6 +28,8 @@
|
||||
<% @recipes.each do |recipe| %>
|
||||
<tr>
|
||||
<td><%= link_to recipe.display_name, recipe %></td>
|
||||
|
||||
<% if current_user? %>
|
||||
<td>
|
||||
<%= link_to edit_recipe_path(recipe), class: 'btn btn-sm btn-primary' do %>
|
||||
<span class="glyphicon glyphicon-pencil"></span>
|
||||
@ -36,6 +40,8 @@
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %>
|
||||
|
||||
<td><%= recipe.yields %></td>
|
||||
<td><%= recipe_time(recipe) %></td>
|
||||
<td><%= timestamp(recipe.created_at) %></td>
|
||||
|
Loading…
Reference in New Issue
Block a user