Validation on subdomain unique

Using Devise on an application with basecamp like subdomains.

You can only register(sign_up) if the account(subdomain) you are
creating is unique.

You can only register(sign_up) from the root domain.

account_name is attr_accessor :account_name in user record and is
created when the user is created (before_create)

Can’t use validates_uniqueness_of :subdomain_name because it is not
part of the record. Creates winny_nil error

I can test it in my create_account method and return false if it is
not unique, but no feedback.

I tried

 validates_uniqueness_of :account_name, :on => :create, :if

=> :check_unique, :message => “Name must be unique”

And returning false does nothing.

Without going into javascript, how can I validate this in the user
record?

I realize this my be a little complicated for this list (and short),
but though I’d give it a try.

No suggestions to this complicated question, so I kept digging.

added before_validation filter on create that Checks if account_name
is not blank and unique. If not unique, it sets it to blank. A
validates_presence_of validation then catches the error and uses a
custom error message.