https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292022-09-19T00:07:19ZRedmineRedmine - Feature #35415: Unified plugin api esp. regarding patcheshttps://www.redmine.org/issues/35415?journal_id=1079372022-09-19T00:07:19Zcrypto gopher
<ul></ul><ol>
<li><code>to_prepare()</code> no longer works as expeted in Rails 6, it is enough to put <code>include()</code> directly in <i>init.rb</i> (<a class="issue tracker-1 status-3 priority-4 priority-default" title="Defect: ActiveSupport::Reloader.to_prepare not working in trunk 21287 (Resolved)" href="https://www.redmine.org/issues/36245">#36245</a>)</li>
<li>when including patch it is redundant to check <code>included_modules</code>, <a class="external" href="https://ruby-doc.org/core-2.7.6/Module.html#method-i-append_features">https://ruby-doc.org/core-2.7.6/Module.html#method-i-append_features</a>:</li>
</ol>
<blockquote>
<p>Ruby's default implementation is to add the constants, methods, and module variables of this module to mod if this module has not already been added to mod or one of its ancestors.</p>
</blockquote>
<p>so your example can be shortened to:</p>
<pre>FooController.include MyPlugin::Patches::FooControllerPatch</pre>