Skip to content

Instantly share code, notes, and snippets.

@larzconwell
Created March 31, 2012 21:15
Show Gist options
  • Save larzconwell/2268624 to your computer and use it in GitHub Desktop.
Save larzconwell/2268624 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
# Original
attr_accessible :name, :email
attr_accessible :name, :email, :location, :as => :location
attr_accessible :name, :email, :location, :admin, :as => :admin
# OR
# Tenderlove style
attr_accessible :name, :email
role :location => [:default] do
attr_accessible :location
end
role :admin => [:default, :location] do
attr_accessible :admin
end
# OR
# My style
attr_accessible :name, :email
attr_accessible :name, :email, :location, :as => :location, inherits: [:default]
attr_accessible :name, :email, :location, :admin, :as => :admin, inherits: [:default, :location]
end
@larzconwell
Copy link
Author

Oops sorry the last style's inherits arg is using Ruby 1.9 syntax, while the rest is Ruby 1.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment