membership gremium scope

This commit is contained in:
Andreas Stephanides
2014-09-14 18:30:56 +02:00
parent b11773ac85
commit e8576d532f
3 changed files with 7 additions and 2 deletions

View File

@@ -33,7 +33,7 @@ class GremienController < ApplicationController
def show def show
@gremium = Gremium.find(params[:id]) @gremium = Gremium.find(params[:id])
@gremientabs=Gremium.tabs @gremientabs=Gremium.tabs
@memberships=@gremium.memberships.active.includes(:fetprofile).order(:typ,"fetprofiles.vorname","fetprofiles.nachname") @memberships=@gremium.memberships.visible_in_gremium
respond_to do |format| respond_to do |format|
format.html # show.html.erb format.html # show.html.erb

View File

@@ -19,6 +19,7 @@ class Membership < ActiveRecord::Base
belongs_to :fetprofile belongs_to :fetprofile
belongs_to :gremium belongs_to :gremium
scope :active, -> {where("stop >= ? OR stop IS NULL", Time.now.to_date)} scope :active, -> {where("stop >= ? OR stop IS NULL", Time.now.to_date)}
scope :visible_in_gremium, ->{active.includes(:fetprofile).order(:typ,"fetprofiles.vorname","fetprofiles.nachname")}
validates :typ, :presence=>true validates :typ, :presence=>true
validates :fetprofile, :presence=>true validates :fetprofile, :presence=>true
validates :start, :presence=>true validates :start, :presence=>true

View File

@@ -1,2 +1,6 @@
<h2><%=fa_icon("users 2x")+ nlink.name %></h2> <h2><%=fa_icon("users 2x")+ nlink.name %></h2>
<p><%= raw(nlink.desc) %></p>
<% nlink.memberships.visible_in_gremium.each do |m| %>
<%= image_tag m.fetprofile.try(:picture).try(:thumb) %>
<% end %>