class Interview::AssociationAttribute
Attributes
association_class[RW]
Protected Instance Methods
build_read(b)
click to toggle source
# File lib/interview/controls/association_attribute.rb, line 8 def build_read(b) return if value.nil? assoc_object = value # todo: Link nicht anzeigen, wenn Route für Objekt nicht existiert b.link parent: self, caption: "#{assoc_object.human_id}", object: assoc_object end
build_write(b)
click to toggle source
# File lib/interview/controls/association_attribute.rb, line 15 def build_write(b) object = @object || find_attribute!(:object) if object.respond_to? "#{method}_pool" pool = object.send "#{method}_pool" elsif @association_class assoc_class = Object.const_get(@association_class.to_s.camelcase) pool = assoc_class.all else assoc_class = object.class.new.send("build_#{@method}").class pool = assoc_class.all end b << form_builder.collection_select("#{@method}_id", pool, :id, :human_id, {include_blank: true}, {class: 'form-control'}) # todo: prompt einbauen end