Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue #2405 - Unable to load Zammad in web browser, because of …
…online notification of ticket which was already deleted in the meantime.
- Loading branch information
1 parent
9bcd07c
commit 629c561
Showing
6 changed files
with
94 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/models/application_model/has_exists_check_by_object_and_id.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ | ||
module ApplicationModel::HasExistsCheckByObjectAndId | ||
extend ActiveSupport::Concern | ||
|
||
class_methods do | ||
|
||
=begin | ||
verify if referenced object exists | ||
success = Model.exists_by_object_and_id('Ticket', 123) | ||
returns | ||
# true or will raise an exception | ||
=end | ||
|
||
def exists_by_object_and_id?(object, o_id) | ||
|
||
begin | ||
local_class = object.constantize | ||
rescue => e | ||
raise "Unable for get an instance of '#{object}': #{e.inspect}" | ||
end | ||
if !local_class.exists?(o_id) | ||
raise ActiveRecord::RecordNotFound, "Unable for find reference object '#{object}.exists?(#{o_id})!" | ||
end | ||
|
||
true | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters