app/views/proposals/index.html.erb
<div class="right">
<% if user_signed_in? %>
<%= link_to new_proposal_path, class:'btn btn-primary' do
I18n.t 'proposal.add_yours'
end %>
<% else %>
<%= link_to new_user_registration_path, class:'btn btn-primary' do
I18n.t 'proposal.add_yours'
end %>
<% end %>
</div>
<h1><%= I18n.t 'activerecord.model.proposal', count: 2 %></h1>
<br/>
<% @proposals.each do |proposal| %>
<div class="card">
<div class="card-body">
<h2>
<span class="badge badge-info badge-pill">
<%= I18n.t 'votable.votes', count: proposal.votes.count %>
</span>
<%= link_to proposal.title, proposal %>
</h2>
<p><%= truncate(strip_tags(@markdown.render(proposal.description)), length: 256) %></p>
<% if policy(proposal).vote? %>
<%= link_to vote_proposal_path(proposal), method: :post, class:'btn btn-primary right' do %>
<%= I18n.t 'main.vote' %>
<% end %>
<% end %>
</div>
<div class="card-footer text-muted">
<%= link_to proposal.user.username, "/#{proposal.user.username}" %> | <%= time_ago_in_words(proposal.created_at) %>
</div>
</div>
<% end %>
<%= paginate @proposals, theme: 'twitter-bootstrap-4' %>