Sha256: c2bb4f09b42e9c5fdd141d8449ac0e9447ae04d564d2f79bdee22ef60e844397

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

<% if user_signed_in? %>
  <% rating = ActsAsStarrable::Rating.find(:first, :conditions => {:rater_type => 'User', :rater_id => current_user.id, :starrable_type => starrable.class, :starrable_id => starrable.id}) %>
  <%= javascript_tag do %>
    window.rater = '<%= current_user.id %>';
    window.rater_type = '<%= current_user.class %>';
    window.rating = <%= rating ? rating.id : 'null' %>;
    window.starrable_type = '<%= starrable.class %>';
  <% end %>
<% end %>
<% if rating %>
  <div class="rateit" data-rateableid="<%= starrable.id %>" data-rateit-value="<%= rating.rating %>" data-rateit-ispreset="false"></div>
  <span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">avg.
    <span itemprop="ratingValue"><%= starrable.average_rating %></span> stars out of
    <span itemprop="bestRating"><%= starrable.max_rating %></span>
    (<span itemprop="ratingCount"><%= pluralize(starrable.ratings.count, 'rating') %></span> total).
  </span>
<% else %>
  <div class="rateit" data-rateableid="<%= starrable.id %>" data-rateit-value="<%= starrable.average_rating %>" data-rateit-ispreset="true" data-rateit-resetable="false" data-rateit-readonly="<%= !user_signed_in? %>"></div>
  <span itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    <span itemprop="ratingValue"><%= starrable.average_rating %></span> stars out of
    <span itemprop="bestRating"><%= starrable.max_rating %></span>
    (<span itemprop="ratingCount"><%= pluralize(starrable.ratings.count, 'rating') %></span> total).
  </span>
<% end %>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_starrable-0.0.2 app/views/starrable/_stars.html.erb