Skip to content

Instantly share code, notes, and snippets.

@zdennis
Created October 1, 2008 00:08
Show Gist options
  • Save zdennis/13991 to your computer and use it in GitHub Desktop.
Save zdennis/13991 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
validate :only_superusers_can_do_foo
private
def superuser?
if account == "Super User"
true
else
false
end
end
def only_superusers_can_do_foo
if !superuser?
errors.add_to_base "Normal users can't do that!"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment