Skip to content

Instantly share code, notes, and snippets.

@larzconwell
Created March 30, 2012 19:48
Show Gist options
  • Save larzconwell/2254417 to your computer and use it in GitHub Desktop.
Save larzconwell/2254417 to your computer and use it in GitHub Desktop.
# 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
@larzconwell
Copy link
Author

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