This repository has been archived on 2020-05-27. You can view files and clone it, but cannot push or open issues/pull-requests.
tuxbliki/app/models/permission.rb

12 lines
354 B
Ruby
Raw Normal View History

2008-06-27 00:13:15 -04:00
class Permission < ActiveRecord::Base
has_and_belongs_to_many :authors
validates_presence_of :name
validates_uniqueness_of :name
def self.author_has_permission_to?(name, author = nil)
p = self.find_by_name(name.to_s)
p ||= self.create :name => name.to_s # auto-create permission if necessary
p.authors.include?(author)
end
end