Created
October 1, 2008 00:08
-
-
Save zdennis/13991 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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