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
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
def ensure_valid_user
|
def ensure_valid_user
|
||||||
if current_user.nil?
|
unless current_user?
|
||||||
flash[:warning] = "You must login"
|
flash[:warning] = "You must login"
|
||||||
redirect_to login_path
|
redirect_to login_path
|
||||||
end
|
end
|
||||||
@ -22,6 +22,11 @@ class ApplicationController < ActionController::Base
|
|||||||
end
|
end
|
||||||
helper_method :current_user
|
helper_method :current_user
|
||||||
|
|
||||||
|
def current_user?
|
||||||
|
!current_user.nil?
|
||||||
|
end
|
||||||
|
helper_method :current_user?
|
||||||
|
|
||||||
def set_current_user(user)
|
def set_current_user(user)
|
||||||
if user
|
if user
|
||||||
session[:user_id] = user.id
|
session[:user_id] = user.id
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th colspan="2"></th>
|
<% if current_user? %>
|
||||||
|
<th colspan="2"></th>
|
||||||
|
<% end %>
|
||||||
<th>Yields</th>
|
<th>Yields</th>
|
||||||
<th>Time</th>
|
<th>Time</th>
|
||||||
<th>Created</th>
|
<th>Created</th>
|
||||||
@ -26,16 +28,20 @@
|
|||||||
<% @recipes.each do |recipe| %>
|
<% @recipes.each do |recipe| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to recipe.display_name, recipe %></td>
|
<td><%= link_to recipe.display_name, recipe %></td>
|
||||||
<td>
|
|
||||||
<%= link_to edit_recipe_path(recipe), class: 'btn btn-sm btn-primary' do %>
|
<% if current_user? %>
|
||||||
<span class="glyphicon glyphicon-pencil"></span>
|
<td>
|
||||||
<% end %>
|
<%= link_to edit_recipe_path(recipe), class: 'btn btn-sm btn-primary' do %>
|
||||||
</td>
|
<span class="glyphicon glyphicon-pencil"></span>
|
||||||
<td>
|
<% end %>
|
||||||
<%= link_to recipe, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-danger' do %>
|
</td>
|
||||||
<span class="glyphicon glyphicon-remove"></span>
|
<td>
|
||||||
<% end %>
|
<%= link_to recipe, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-danger' do %>
|
||||||
</td>
|
<span class="glyphicon glyphicon-remove"></span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<td><%= recipe.yields %></td>
|
<td><%= recipe.yields %></td>
|
||||||
<td><%= recipe_time(recipe) %></td>
|
<td><%= recipe_time(recipe) %></td>
|
||||||
<td><%= timestamp(recipe.created_at) %></td>
|
<td><%= timestamp(recipe.created_at) %></td>
|
||||||
|
Loading…
Reference in New Issue
Block a user