Sha256: a48ab0e0e8c2f7e707ec091891427111f0ab180496fbe4e6ce1ca6b365602ffa
Contents?: true
Size: 656 Bytes
Versions: 37
Compression:
Stored size: 656 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 unless label.present? 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
37 entries across 37 versions & 1 rubygems