Permalink
Browse files

Making sure non-admin models have the correct links. Added other aest…

…hetics.
  • Loading branch information...
1 parent 28e4086 commit 86570bde17a8e72450ee283f9719c32037872354 Rian Rainey committed Jan 30, 2013
@@ -2,7 +2,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery
def require_admin
- unless user_signed_in? and current_user.has_role? "Admin"
+ unless user_signed_in? and current_user.has_role?(["Super Admin", "Admin"])
flash[:error] = "You must be an admin to access this section."
redirect_to root_path # halts request cycle
end
@@ -4,15 +4,13 @@
<%= link_to "CrossFit West Nashville", root_path, id: "logo" %>
<div class="navbar">
<ul class="nav pull-right">
-
- <li><%= link_to "Home", root_path %></li>
-
+ <li><%= link_to "Workouts", workouts_path %></li>
<% if user_signed_in? # Devise function %>
- <li><%= link_to "Workouts", workouts_index_path %></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Me<b class="caret"></b></a>
<ul class="dropdown-menu">
- <li><%= link_to "My Profile", user_path(current_user) %></li>
+ <li><%= link_to "My Workouts", workouts_path %></li>
+ <li><%= link_to "My Profile", user_path(current_user.id) %></li>
<li class="divider"></li>
<li>
<%= link_to "Log Out", destroy_user_session_path,
@@ -24,14 +22,16 @@
</li>
- <% if current_user.has_role? "Admin" %>
+ <% if current_user.has_role? ["Super Admin", "Admin"] %>
<div class="btn-group" style="float:left; display:inline;">
<a class="btn btn-success dropdown-toggle" data-toggle="dropdown" href="#">
Admin
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><%= link_to "Users", admin_users_path %></li>
+ <li><%= link_to "Roles", admin_roles_path %></li>
+ <li><%= link_to "Workouts", admin_workouts_path %></li>
</ul>
</div>
<% end %>
@@ -46,4 +46,4 @@
</div>
</div>
</div>
-</header>
+</header>
@@ -2,5 +2,5 @@
<%= render 'form' %>
-<%= link_to 'Show', edit_admin_user_path %> |
+<%= link_to 'Show', edit_user_path %> |
<%= link_to 'Back', user_path %>
@@ -15,5 +15,5 @@
</p>
-<%= link_to 'Edit', edit_admin_user_path(@user) %> |
-<%= link_to 'Back', admin_users_path %>
+<%= link_to 'Edit', edit_user_path(@user) %> |
+<%= link_to 'Back', user_path %>
@@ -1,4 +1,4 @@
-<h1>Listing workouts</h1>
+<h1>All Workouts</h1>
<table class="table table-striped">
<tr>
@@ -12,14 +12,21 @@
<td><%= workout.title %></td>
<td><%= workout.body %></td>
<td>
+ <% if user_signed_in? %>
+ <ul class="inline">
+ <li><%= link_to 'Add Entry', new_workout_entry_path(workout) %></li>
+ </ul>
+ <% end %>
+ <% if current_user.has_role? "Admin" %>
<div class="btn-group">
<a href="#" class="btn dropdown-toggle" data-toggle="dropdown">Action<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><%= link_to 'Show', admin_workout_path(workout) %></li>
<li><%= link_to 'Edit', edit_admin_workout_path(workout) %></li>
<li><%= link_to 'Destroy', admin_workout_path(workout), method: :delete, data: { confirm: 'Are you sure?' } %></li>
</ul>
- </div>
+ </div>
+ <% end %>
</td>
</tr>
@@ -28,4 +35,6 @@
<br />
-<%= link_to 'New Workout', new_admin_workout_path %>
+<% if current_user.has_role? "Admin" %>
+ <%= link_to 'New Workout', new_admin_workout_path %>
+<% end %>

0 comments on commit 86570bd

Please sign in to comment.