Sha256: 2e85fadc9fff3b276e597ab360ceb5a02071c6af2af8fdcabc865c01ada9fc0d
Contents?: true
Size: 650 Bytes
Versions: 202
Compression:
Stored size: 650 Bytes
Contents
module Katello module Ext module LabelFromName def self.included(base) base.class_eval do before_validation :setup_label_from_name validate :label_not_changed, :on => :update end end def setup_label_from_name if label.blank? self.label = Util::Model.labelize(name) if self.class.where(:label => self.label).any? self.label = Util::Model.uuid end end end def label_not_changed if label_changed? && label_was.present? errors.add(:label, _("cannot be changed.")) end end end end end
Version data entries
202 entries across 202 versions & 1 rubygems