Skip to content

Instantly share code, notes, and snippets.

Created March 9, 2010 07:55
Show Gist options
  • Select an option

  • Save anonymous/326365 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/326365 to your computer and use it in GitHub Desktop.
class Comment < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
title :string, :required, :name => true, :primary_content => true
comment :text, :required
internal :boolean
timestamps
end
belongs_to :owner, :class_name => "User", :creator => true
belongs_to :version, :accessible => true
#never_show :owner
# --- Permissions --- #
def emailoptout?(user)
!user.email_optout?
end
def create_permitted?
acting_user.administrator? || version.creatable_by?(acting_user)
end
def update_permitted?
acting_user.administrator?
end
def destroy_permitted?
acting_user.administrator?
end
def view_permitted?(field)
acting_user.administrator? || !internal
end
def owner_view_permitted?
true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment