Sha256: 0d27bc6502068d2770001358d37d8717671d087097e0d21166c861546101a131
Contents?: true
Size: 864 Bytes
Versions: 2
Compression:
Stored size: 864 Bytes
Contents
class Post < ActiveRecord::Base belongs_to :user, :touch => true has_many :comments include Garage::Representer include Garage::Authorizable property :id property :title property :body, selectable: accessible(PostBody) property :tag, as: :label, selectable: true property :user, selectable: true collection :comments, selectable: true link(:self) { post_path(self) } def tag 'cat' end def owner user end def build_permissions(perms, other) perms.permits! :read perms.permits! :write if owner == other end def self.build_permissions(perms, other, target) if target[:user] perms.permits! :read, :write if target[:user] == other else # public resource i.e. /posts perms.permits! :read, :write end end def self.garage_examples(user) [:posts_path, Post.first] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
garage-doorkeeper-2.0.0 | spec/dummy/app/models/post.rb |
garage-doorkeeper-1.0.0 | spec/dummy/app/models/post.rb |