Created
February 21, 2011 01:06
-
-
Save NickClark/836501 to your computer and use it in GitHub Desktop.
Is there not a better way?
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
# So i want to have quick access to some standard roles in my Roles table | |
# The following works, but I am regenerating my table for scratch, and I run | |
# rake db:schema:load, then I get errors because rails loads all the code first, | |
# and when it gets to these class methods, it errors out since it cant find the | |
# roles table yet. Which is exactly what I am trying to do!! Any Ideas how I can improve this? | |
Class Role < ActiveRecord::Base | |
def self.admin | |
find_by_name "Administrator" | |
end | |
def self.user | |
find_by_name "User" | |
end | |
def self.moderator | |
find_by_name "Moderator" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment