2014-03-26 11:09:39 +00:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: locks
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# lockable_type :string(255)
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
2020-03-18 03:38:17 +00:00
|
|
|
# lockable_id :integer
|
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
|
|
|
# index_locks_on_lockable_id_and_lockable_type (lockable_id,lockable_type)
|
2014-03-26 11:09:39 +00:00
|
|
|
#
|
|
|
|
|
2014-03-23 00:22:25 +00:00
|
|
|
class Lock < ActiveRecord::Base
|
|
|
|
include Extra
|
|
|
|
belongs_to :lockable, :polymorphic => true
|
|
|
|
|
|
|
|
def can_create? cuser
|
|
|
|
cuser and cuser.admin?
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_destroy? cuser
|
|
|
|
cuser and cuser.admin?
|
|
|
|
end
|
2020-03-18 03:38:17 +00:00
|
|
|
|
|
|
|
def self.params(params, cuser)
|
|
|
|
params.require(:lock).permit(:lockable_type, :lockable_id)
|
|
|
|
end
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|