app/views/rostra/shared/_votes.html.erb in rostra-0.0.3 vs app/views/rostra/shared/_votes.html.erb in rostra-0.0.4
- old
+ new
@@ -1,27 +1,19 @@
<div class="vote_wrapper">
-
- <% if user_signed_in? %>
-
- <% up_selected = current_user.voted_for?(@question) ? 'selected' : "" %>
- <%= link_to('Vote Question Up', vote_question_path(@question, vote_type: 'up'), method: :put, remote: true, class: "vote up #{up_selected}") %>
-
- <div class="count"><%= @question.plusminus %></div>
-
- <% down_selected = current_user.voted_against?(@question) ? 'selected' : "" %>
- <%= link_to('Vote Question Down', vote_question_path(@question, vote_type: 'down'), method: :put, remote: true, class: "vote down #{down_selected}") %>
-
- <% else %>
-
- <%= link_to('Vote Question Up', '#', class: "vote up login_flash") %>
- <div class="count"><%= @question.plusminus %></div>
- <%= link_to('Vote Question Down', '#', class: "vote down login_flash") %>
-
- <% end %>
-
+ <%= link_to_vote(:up, resource) %>
+ <div class="count"><%= resource.plusminus %></div>
+ <%= link_to_vote(:down, resource) %>
</div>
<% unless user_signed_in? %>
<div class="hidden flash" id="flash_notice">
- You must <%= link_to 'login', main_app.new_user_session_path %> or <%= link_to 'signup', main_app.new_user_registration_path %> in order to vote
+ You must <%= link_to 'login', main_app_login_path %> or <%= link_to 'signup', main_app_signup_path %> in order to vote
+ <%= link_to 'close', '#', class: 'close' %>
</div>
-<% end %>
\ No newline at end of file
+<% end %>
+
+<% if can? :manage, resource %>
+ <div class="hidden flash" id="flash_notice">
+ You cannot vote on your own <%= class_name(resource) %>
+ <%= link_to 'close', '#', class: 'close' %>
+ </div>
+<% end %>