Skip to content

Instantly share code, notes, and snippets.

@xander-miller
Forked from fresh5447/wikis.index.html.erb
Last active August 29, 2015 14:01
Show Gist options
  • Save xander-miller/9d05ade05d9b7f4e4dcd to your computer and use it in GitHub Desktop.
Save xander-miller/9d05ade05d9b7f4e4dcd to your computer and use it in GitHub Desktop.
<h1>My wikis</h1>
<div class="row">
<% if policy(Wiki.new).create? %> <%#added policy instead of if user %>
<%= link_to 'New', new_wiki_path, class: 'btn btn-primary btn-large' %>
<% end %>
<% if current_user.role?("free") %>
<h2><%= link_to "Upgrade Account", new_charge_path, class: 'btn btn-primary btn-large' %></h2>
</div>
<% end %>
<table class="table table-bordered">
<thead>
<tr class="info">
<th>User</th>
<th>Name</th>
<th>Body</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @wikis.each do |wiki| %>
<tr class="active">
<td><%= wiki.user.name if wiki.user %></td>
<td><%= wiki.name %></td>
<td><%= wiki.body %></td>
<td><%= link_to 'Show', wiki %> |
<% if policy(wiki).edit? %>
<%= link_to 'Edit', edit_wiki_path(wiki) %>
<% end %> |
<% if policy(wiki).destroy? %>
<%= link_to 'Destroy', wiki, method: :delete, data: { confirm: 'Are you sure?' } %>
<% end %>
<%# if current_user.role?("premium") %>
<%# link_to 'Add Collaborators', new_wiki_collaborator_path(wiki) %>
<%# end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<br>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment