Sha256: 78ec3113c894eb4b55cc814ab062a55f9b6fc1ea03435718d7d2d8b7ebaca43f

Contents?: true

Size: 458 Bytes

Versions: 23

Compression:

Stored size: 458 Bytes

Contents

module ActiveUUID
  module UUID
    def self.included(base)
      base.before_validation :fix_uuid_strings
    end

    def fix_uuid_strings
      self.class.columns_hash.each do |key, fk|
        next unless fk.type == :binary && fk.limit == 255 && /^.+_id$/.match(key.to_s)
        value = self.send fk.name
        if !value.blank? && value.class != UUIDTools::UUID
          self.send "#{fk.name}=", value.to_uuid
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
iugusdk-1.0.11 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.10 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.9 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.8 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.7 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.6 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.5 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.4 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.3 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.2 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.1 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.0.alpha.32 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.0.alpha.31 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.0.alpha.30 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.0.alpha.29 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.0.alpha.28 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.0.alpha.27 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.0.alpha.26 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.0.alpha.25 lib/iugusdk/uuid_mass_assignment_fix.rb
iugusdk-1.0.0.alpha.24 lib/iugusdk/uuid_mass_assignment_fix.rb