Skip to content

Instantly share code, notes, and snippets.

@dmix
Created December 4, 2009 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmix/248808 to your computer and use it in GitHub Desktop.
Save dmix/248808 to your computer and use it in GitHub Desktop.
#live_validations_controller.rb
class LiveValidationsController < ApplicationController
def validate_username
if params[:username].length > 3
@user = User.find_by_username(params[:username])
if @user.nil?
@message = "<img src='/images/accept.png' alt='Valid Username'/>"
else
@message = "<img src='/images/cross.png' alt='Invalid Username' /> Name taken"
end
else
@message = ""
end
render :partial => "message"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment