<%= render 'rostra/shared/sidebar' %>
<%= render partial: 'rostra/shared/votes', locals: { resource: @question } %> <%= rostra_user_avatar(@question.user) %> Asked by <%= link_to_profile(@question.user) %> <%= link_to 'edit', edit_question_path(@question) if can? :manage, @question %>
<%= @question.details.html_safe %>
<%= time_ago_in_words(@question.updated_at) %> ago
<%= tag_list(@question) %>
<% unless @answers.empty? %>

<%= pluralize(@answers.size, 'Answer') %>

<% @answers.each do |answer| %>
<%= render partial: 'rostra/shared/votes', locals: { resource: answer } %> <%= rostra_user_avatar(answer.user) %> <%= link_to_profile(answer.user) %> says: <%= link_to('edit', edit_question_answer_path(@question, answer)) if can? :manage, answer %>
<%= answer.text.html_safe %>
<%= time_ago_in_words(answer.updated_at) %> ago
<% if answer.comments.any? %>
<% answer.comments.each do |comment| %>
<%= comment.comment %>
<%= link_to_profile(comment.user) %> – <%= time_ago_in_words(comment.updated_at) %> ago <% if can? :manage, comment %> <%= link_to('edit', question_comment_path(@question, comment), class: 'edit_comment') %> <%= link_to('delete', question_comment_path(@question, comment), method: :delete, confirm: 'Are you sure?') %> <% end %>
<% end %>
<% end %> <% if can? :manage, Comment %> <%= link_to("comment on this answer", '#', class: 'leave_comment') %> <% else %> <%= link_to("login to leave comment", main_app_login_path) %> <% end %> <% if can? :manage, Comment %> <%= simple_form_for [@question, answer.comments.build], validate: true do |f| %> <% # TODO: Should not need hidden fields. Why doesn't build apply the foreign keys? %> <%= f.hidden_field :user_id, value: rostra_user.id %> <%= f.hidden_field :commentable_id, value: answer.id %> <%= f.hidden_field :commentable_type, value: "Rostra::Answer" %> <%= f.input :comment, label: '' %> <%= f.submit 'post comment' %> <% end %> <% end %>
<% end %>
<% end %> <%= link_to "Add a new answer", new_question_answer_path(@question), class: 'button' %> <% if can_participate_in_rostra? %> <%= render 'rostra/answers/form' %> <% else %> <%= link_to "Login to answer this question", main_app_login_path, class: 'button' %> <% end %>