https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292018-06-01T04:35:27ZRedmineRedmine - Defect #28925: Custom field values for enumerations not savedhttps://www.redmine.org/issues/28925?journal_id=853182018-06-01T04:35:27ZGo MAEDA
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Confirmed</i></li><li><strong>Priority</strong> changed from <i>Low</i> to <i>Normal</i></li><li><strong>Target version</strong> set to <i>Candidate for next minor release</i></li></ul> Redmine - Defect #28925: Custom field values for enumerations not savedhttps://www.redmine.org/issues/28925?journal_id=853192018-06-01T04:41:24ZGo MAEDA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-6 priority-highest closed" href="/issues/26564">Defect #26564</a>: Enumerations sorting does not work</i> added</li></ul> Redmine - Defect #28925: Custom field values for enumerations not savedhttps://www.redmine.org/issues/28925?journal_id=856272018-06-18T05:44:15ZMizuki ISHIKAWA
<ul><li><strong>File</strong> <a href="/attachments/20896">fix_28925.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/20896/fix_28925.patch">fix_28925.patch</a> added</li></ul><p>I wrote a patch to fix this defect.<br />The key of custom_field_values allows only id of custom field of enumeration.</p> Redmine - Defect #28925: Custom field values for enumerations not savedhttps://www.redmine.org/issues/28925?journal_id=856302018-06-18T06:18:31ZMizuki ISHIKAWA
<ul><li><strong>File</strong> <a href="/attachments/20897">fix_28925_v2.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/20897/fix_28925_v2.patch">fix_28925_v2.patch</a> added</li></ul><p>I changed the test a little.</p> Redmine - Defect #28925: Custom field values for enumerations not savedhttps://www.redmine.org/issues/28925?journal_id=856432018-06-18T15:38:38ZGo MAEDA
<ul></ul><p>Maybe we can use <code>available_custom_fields</code> to collect ids of custom fields. I think the following change can make the patch simpler and faster. Mizuki, do you think it is correct?</p>
<pre><code class="diff syntaxhl"><span class="gd">--- app/controllers/enumerations_controller.rb.orig 2018-06-18 15:28:18.000000000 +0000
</span><span class="gi">+++ app/controllers/enumerations_controller.rb 2018-06-18 15:28:36.000000000 +0000
</span><span class="p">@@ -107,7 +107,7 @@</span>
def enumeration_params
# can't require enumeration on #new action
<span class="gd">- custom_field_keys = (@enumeration.try(:custom_field_values) || []).map{|c| c.custom_field_id.to_s}
</span><span class="gi">+ custom_field_keys = @enumeration.available_custom_fields.map{|c| c.id.to_s}
</span> params.permit(:enumeration => [:name, :active, :is_default, :position, :custom_field_values => custom_field_keys])[:enumeration]
end
end
</code></pre> Redmine - Defect #28925: Custom field values for enumerations not savedhttps://www.redmine.org/issues/28925?journal_id=856452018-06-18T17:54:06ZPavel Rosický
<ul></ul><p>why enumerations use strong params instead of safe_attributes like all other models do?</p> Redmine - Defect #28925: Custom field values for enumerations not savedhttps://www.redmine.org/issues/28925?journal_id=856522018-06-18T23:45:23ZMizuki ISHIKAWA
<ul></ul><p>Go MAEDA wrote:</p>
<blockquote>
<p>Maybe we can use <code>available_custom_fields</code> to collect ids of custom fields. I think the following change can make the patch simpler and faster. Mizuki, do you think it is correct?</p>
<p>[...]</p>
</blockquote>
<p>I did not know available_custom_fields. I think that the code you propose is good.</p>
<p>Pavel Rosický wrote:</p>
<blockquote>
<p>why enumerations use strong params instead of safe_attributes like all other models do?</p>
</blockquote>
<p>I do not know the reason, It seems that it was intentionally changed to use strong_params instead of safe_attribute in <a class="changeset" title="Permit enumeration params." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/16602">r16602</a> and <a class="changeset" title="Use strong params for CustomFieldEnumeration." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/16603">r16603</a>.</p> Redmine - Defect #28925: Custom field values for enumerations not savedhttps://www.redmine.org/issues/28925?journal_id=856532018-06-19T00:49:31ZGo MAEDA
<ul><li><strong>File</strong> <a href="/attachments/20907">fix_28925_v3.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/20907/fix_28925_v3.patch">fix_28925_v3.patch</a> added</li><li><strong>Target version</strong> changed from <i>Candidate for next minor release</i> to <i>3.4.7</i></li></ul><p>Mizuki ISHIKAWA wrote:</p>
<blockquote>
<p>I did not know available_custom_fields. I think that the code you propose is good.</p>
</blockquote>
<p>Thank you for reviewing the change I suggested in <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Defect: Custom field values for enumerations not saved (Closed)" href="https://www.redmine.org/issues/28925#note-5">#28925#note-5</a>. I have slightly changed your patch.</p>
<p>Setting target version to 3.4.7.</p> Redmine - Defect #28925: Custom field values for enumerations not savedhttps://www.redmine.org/issues/28925?journal_id=872882018-09-15T06:48:54ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Status</strong> changed from <i>Confirmed</i> to <i>Closed</i></li><li><strong>Assignee</strong> set to <i>Jean-Philippe Lang</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Committed, thanks.</p> Redmine - Defect #28925: Custom field values for enumerations not savedhttps://www.redmine.org/issues/28925?journal_id=873222018-09-15T09:09:11ZJean-Philippe Langjp_lang@yahoo.fr
<ul></ul><p>Patch broke 3.4-stable, fixed.</p>