app/models/inline_image.rb
# We should be able to use validates_uniqueness_of for this, but Rails is completely
# brain-damaged: it only lets you specify an error message that starts with the name
# of the column, capitalized, so if we say "foo", the message is "Md5 foo".  This is
# useless.
We should be able to use validates_uniqueness_of for this, but Rails is completely
brain-damaged: it only lets you specify an error message that starts with the name
of the column, capitalized, so if we say "foo", the message is "Md5 foo".  This is
useless.
We should be able to use validates_uniqueness_of for this but Rails is completely brain - damaged : it only lets you specify an error message that starts with the name of the column capitalized so if we say " foo " the message is " Md5 foo " . This is useless .
def validate_uniqueness
    siblings = inline.inline_images
    for s in siblings do
      next if s.id == self
      if s.md5 == md5
        errors.add(:base, "##{s.sequence} already exists.")
        return false
      end
    end
    true
  end
def validate_uniqueness siblings = inline . inline_images for s in siblings do next if s . id == self if s . md5 == md5 errors . add ( :base , "##{s.sequence} already exists." ) return false end end true end
We should be able to use validates_uniqueness_of for this, but Rails is completely
brain-damaged: it only lets you specify an error message that starts with the name
of the column, capitalized, so if we say "foo", the message is "Md5 foo".
We should be able to use validates_uniqueness_of for this but Rails is completely brain - damaged : it only lets you specify an error message that starts with the name of the column capitalized so if we say " foo " the message is " Md5 foo " .