ensl.org/app/models/lock.rb
2020-03-26 04:26:30 +02:00

31 lines
645 B
Ruby

# == Schema Information
#
# Table name: locks
#
# id :integer not null, primary key
# lockable_type :string(255)
# created_at :datetime
# updated_at :datetime
# lockable_id :integer
#
# Indexes
#
# index_locks_on_lockable_id_and_lockable_type (lockable_id,lockable_type)
#
class Lock < ActiveRecord::Base
include Extra
belongs_to :lockable, :polymorphic => true, :optional => true
def can_create? cuser
cuser and cuser.admin?
end
def can_destroy? cuser
cuser and cuser.admin?
end
def self.params(params, cuser)
params.require(:lock).permit(:lockable_type, :lockable_id)
end
end