class ContactField < ActiveRecord::Base has_one :contactee, :dependent => :destroy#, :include=>:contactable delegate :contactable, :contactable=, :to => :contactee validates_presence_of :name, :message => 'cannot be empty' FIELD_TYPES = { :text => 'Texto corto', :textarea => 'Texto largo', :email => 'Email', :int => 'Numero', :checkbox => 'Si/no', :password => 'Contraseña' } def field_type=(f) f = FIELD_TYPES.include?(f.to_sym) ? f : :text write_attribute('field_type',f.to_s) end end