diff options
author | Marius Balteanu <marius.balteanu@zitec.com> | 2024-02-27 07:06:47 +0000 |
---|---|---|
committer | Marius Balteanu <marius.balteanu@zitec.com> | 2024-02-27 07:06:47 +0000 |
commit | 18cb44684b79d23dc1c45e4a9eeeb73dda5e9194 (patch) | |
tree | fabbf5c35715e1d1a5429c93b04aa5668487aad0 /lib | |
parent | 38d950df55ed1ed7180c0a9b25f47f18dee583da (diff) | |
download | redmine-18cb44684b79d23dc1c45e4a9eeeb73dda5e9194.tar.gz redmine-18cb44684b79d23dc1c45e4a9eeeb73dda5e9194.zip |
Introduces Redmine::Plugin#attachment_object_type to provide better API for registering plugin models having attachments (#39948, #39862).
Patch by Jens Krämer (@jkraemer).
git-svn-id: https://svn.redmine.org/redmine/trunk@22747 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/plugin.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb index c750c492d..17a20f5a8 100644 --- a/lib/redmine/plugin.rb +++ b/lib/redmine/plugin.rb @@ -428,6 +428,18 @@ module Redmine Redmine::WikiFormatting.register(name, *args) end + # Register plugin models that use acts_as_attachable. + # + # Example: + # attachment_object_type SomeAttachableModel + # + # This is necessary for the core attachments controller routes and attachments/_form to work. + def attachment_object_type(*args) + args.each do |klass| + Redmine::Acts::Attachable::ObjectTypeConstraint.register_object_type(klass.name.underscore.pluralize) + end + end + # Returns +true+ if the plugin can be configured. def configurable? settings && settings.is_a?(Hash) && settings[:partial].present? |