Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<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