Skip to content

Instantly share code, notes, and snippets.

Created January 3, 2013 15:34
Show Gist options
  • Save anonymous/4444325 to your computer and use it in GitHub Desktop.
Save anonymous/4444325 to your computer and use it in GitHub Desktop.
# Mapping to a view
class RekenserviceRated
include DataMapper::Resource
storage_names[:default] = 'rekenservice_rated'
is :read_only
property :rating, Float
property :count, Integer
belongs_to :rekenservice, :key => true
belongs_to :category, :key => true
end
<%- i = 0 %>
<% data = group_by_category(RekenserviceRated.all(:order => [:rating.desc])) %>
<% not_used_categories = Category.all(:id.not => data.keys.map{|c| c.id })%>
<% data.each do |category, rekenservices| %>
<% if i % 3 == 0 %>
<div class="row">
<% end %>
<% if i % 3 == 2 || data.length - 1 == i %>
</div>
<% end %>
<%- i= i+1 -%>
<% end %>
<p>
Voor de volgende categorieën zijn er bij ons nog geen rekenservices bekend:
<%= not_used_categories.to_a.map {|c| c.name}.join ", "%>. Bent u de eerste om
<%= link_to "uw rekenservice", new_registration_path(:user) %> aan te melden
in deze categorie?
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment