summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2022-10-20 04:14:26 +0000
committerGo MAEDA <maeda@farend.jp>2022-10-20 04:14:26 +0000
commit8bc9d2abdff3cfc7288ceff85962c90fcca61c43 (patch)
tree34500506350e2a046d3d31f0c8a42129004b9185
parentaeabd4682a3ff98a6e7d6b5ed0c7091937964033 (diff)
downloadredmine-8bc9d2abdff3cfc7288ceff85962c90fcca61c43.tar.gz
redmine-8bc9d2abdff3cfc7288ceff85962c90fcca61c43.zip
Simplify AttachmentsController#find_container (#37772).
Patch by Jens Krämer. git-svn-id: https://svn.redmine.org/redmine/trunk@21907 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/attachments_controller.rb15
1 files changed, 3 insertions, 12 deletions
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 612e070d2..210cd7ba4 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -219,19 +219,10 @@ class AttachmentsController < ApplicationController
end
def find_container
- klass =
- begin
- params[:object_type].to_s.singularize.classify.constantize
- rescue
- nil
- end
- unless klass && (klass.reflect_on_association(:attachments) || klass.method_defined?(:attachments))
- render_404
- return
- end
-
+ # object_type is constrained to valid values in routes
+ klass = params[:object_type].to_s.singularize.classify.constantize
@container = klass.find(params[:object_id])
- if @container.respond_to?(:visible?) && !@container.visible?
+ unless @container.visible?
render_403
return
end