
I had a User class, which then had a Moderator class. I was using the “type” field in my database to denote whether a user was a User or a Moderator. However, my validations weren’t working as I expected:
validates_as_unique :name, :email
Users could have the same email address as Moderators. Obviously sometimes this kind of scoping makes sense for STI classes, but it doesn’t here. I ended up writing this:
module ActiveRecord
module Validations
module ClassMethods
# Intended for use with STI tables, helps ignore the type field
def validates_overall_u…
I often annoys me when people don’t make it clear what they’re referencing in an article. Sometimes people don’t give any references at all, and when they do they use links on words that shouldn’t be links (the click here syndrome).
So I wrote this Javascript to help out. It adds a section at the bottom of each of your Wordpress posts containing all the links you referred to in a post:
/* From Prototype /
document.getElementsByClassName = function(className) {
var children = document.getElementsByTagName(‘‘) || document.all;
var elements = new Array();
for (var i =...