Created
March 30, 2012 19:48
-
-
Save larzconwell/2254417 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
# Before role inheritance | |
class User < ActiveRecord::Base | |
attr_accessible :fname, :lname, :email, :password, :password_digest | |
attr_accessible :fname, :lname, :email, :password, :password_digest, :admin, :as => :admin | |
end | |
# After role inheritance | |
class User < ActiveRecord::Base | |
attr_accessible :fname, :lname, :email, :password, :password_digest | |
attr_accessible :admin, :as => :admin, :inherit => :default # Inherits all the available attributes of the default role | |
end |
Ah! That's a lot better than what I was thinking, it's more obvious what your doing and is cleaner with the block syntax.
I think I may try to do this for my first Rails contribution!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it would be nicer if we had a block syntax for this or something. Like:
Then we wouldn't have to do hash methods.