Skip to content

Instantly share code, notes, and snippets.

@owendall
Created January 11, 2010 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owendall/274717 to your computer and use it in GitHub Desktop.
Save owendall/274717 to your computer and use it in GitHub Desktop.
class Contact < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
name :string
timestamps
end
belongs_to :title
# --- Permissions --- #
def create_permitted?
acting_user.administrator?
end
def update_permitted?
acting_user.administrator?
end
def destroy_permitted?
acting_user.administrator?
end
def view_permitted?(field)
true
end
end
http://screencast.com/t/ZGFmZDQ0NT
http://screencast.com/t/ZjRlM2I5OGIt
class Title < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
name :string
timestamps
end
has_many :contacts
# --- Permissions --- #
def create_permitted?
acting_user.administrator?
end
def update_permitted?
acting_user.administrator?
end
def destroy_permitted?
acting_user.administrator?
end
def view_permitted?(field)
true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment