attachments has_many for document, neuigkeit, thema

This commit is contained in:
Andreas Stephanides
2015-04-07 23:23:14 +02:00
parent 04b6bcac8a
commit 080150f11b
4 changed files with 6 additions and 1 deletions

View File

@@ -21,6 +21,7 @@ class DocumentsController < ApplicationController
@parent=@document.parent
respond_to do |format|
format.js
format.html
end
end

View File

@@ -9,6 +9,7 @@ class Document < ActiveRecord::Base
validate :parent, :presence=>true
has_paper_trail
TYPS = { 1=>"fet_docs", 10=>"protocol", 11=> "agenda"}
has_many :attachments, :as=>:parent
def long_name
if self.parent.class=="Meeting"
"<b>"+self.parent.text+ "</b>"+ self.name

View File

@@ -20,6 +20,9 @@ class Neuigkeit < ActiveRecord::Base
has_many :calentries, as: :object
has_many :nlinks
has_one :meeting
has_many :attachments, :as=>:parent
validates :rubrik, :presence=>true
validates :author, :presence=>true

View File

@@ -22,7 +22,7 @@ class Thema < ActiveRecord::Base
# Each topic has multiple questions, that are also referenced in the FAQ.
has_many :fragen
# Attachments can be all data formats
has_many :attachments
has_many :attachments, :as=>:parent
# attached pics can be used as title pictures
has_many :titlepics, :as=>:parent, :class_name=>'Attachment', :conditions=>{:flag_titlepic=>true}
# each topic has to belong to one group