Sha256: 7fac62d884fef8f91ab5b3c04a9e76452c3fb06c57a8a8591c762d3c95fe75b9
Contents?: true
Size: 806 Bytes
Versions: 9
Compression:
Stored size: 806 Bytes
Contents
class <%= class_name %> < ActiveRecord::Base acts_as_indexed :fields => [:<%= attributes.collect{ |attribute| attribute.name if attribute.type.to_s =~ /string|text/ }.compact.uniq.join(", :") %>] <% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %> validates_presence_of :<%= title.name %> validates_uniqueness_of :<%= title.name %> <% end -%> <% attributes.collect{|a| a if a.type.to_s == 'image'}.compact.uniq.each do |a| -%> belongs_to :<%= a.name.gsub("_id", "") %><%= ", :class_name => 'Image'" unless a.name =~ /^image(_id)?$/ %> <% end -%> <% attributes.collect{|a| a if a.type.to_s == 'resource'}.compact.uniq.each do |a| -%> belongs_to :<%= a.name.gsub("_id", "") %><%= ", :class_name => 'Resource'" unless a.name =~ /^resource(_id)?$/ %> <% end -%> end
Version data entries
9 entries across 9 versions & 1 rubygems