|
|
|
@ -23,8 +23,6 @@ class Hack < ApplicationRecord
|
|
|
|
|
scope :opening, -> {where(open_or_not: 1)}
|
|
|
|
|
scope :mine, -> (author_id){ where(user_id: author_id) }
|
|
|
|
|
|
|
|
|
|
after_destroy :send_delete_tiding
|
|
|
|
|
|
|
|
|
|
def language
|
|
|
|
|
if hack_codes.count == 1
|
|
|
|
|
hack_codes.first.language
|
|
|
|
@ -53,13 +51,4 @@ class Hack < ApplicationRecord
|
|
|
|
|
user_id == user.id || user.admin_or_business?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
def send_delete_tiding
|
|
|
|
|
base_attrs = {
|
|
|
|
|
user_id: user_id, viewed: 0, tiding_type: 'System', trigger_user_id: User.current.id,
|
|
|
|
|
parent_container_type: "HackDelete"
|
|
|
|
|
}
|
|
|
|
|
tidings.create!(base_attrs)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|