diff options
author | Go MAEDA <maeda@farend.jp> | 2018-10-06 16:03:26 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2018-10-06 16:03:26 +0000 |
commit | e159928e6b81c02001411e7e886208533178c0ba (patch) | |
tree | 41c78911f17078c798e5fdc1362b7c18aff138d2 /lib/redmine | |
parent | 323ef3182bc45184c7a14e3a8dc7244850baabed (diff) | |
download | redmine-e159928e6b81c02001411e7e886208533178c0ba.tar.gz redmine-e159928e6b81c02001411e7e886208533178c0ba.zip |
Use find_by instead of where.first to remove unnecessary sorting (#26747).
Patch by Yuichi HARADA.
git-svn-id: http://svn.redmine.org/redmine/trunk@17586 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine')
-rw-r--r-- | lib/redmine/field_format.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index c4960c0f7..4d168b434 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -155,7 +155,7 @@ module Redmine def target_class nil end - + def possible_custom_value_options(custom_value) possible_values_options(custom_value.custom_field, custom_value.customized) end @@ -625,7 +625,7 @@ module Redmine value ||= label checked = (custom_value.value.is_a?(Array) && custom_value.value.include?(value)) || custom_value.value.to_s == value tag = view.send(tag_method, tag_name, value, checked, :id => nil) - s << view.content_tag('label', tag + ' ' + label) + s << view.content_tag('label', tag + ' ' + label) end if custom_value.custom_field.multiple? s << view.hidden_field_tag(tag_name, '', :id => nil) @@ -730,7 +730,7 @@ module Redmine def reset_target_class @target_class = nil end - + def possible_custom_value_options(custom_value) options = possible_values_options(custom_value.custom_field, custom_value.customized) missing = [custom_value.value_was].flatten.reject(&:blank?) - options.map(&:last) @@ -776,7 +776,7 @@ module Redmine class EnumerationFormat < RecordList add 'enumeration' self.form_partial = 'custom_fields/formats/enumeration' - + def label "label_field_format_enumeration" end @@ -964,7 +964,7 @@ module Redmine end else if custom_value.value.present? - attachment = Attachment.where(:id => custom_value.value.to_s).first + attachment = Attachment.find_by(:id => custom_value.value.to_s) extensions = custom_value.custom_field.extensions_allowed if attachment && extensions.present? && !attachment.extension_in?(extensions) errors << "#{::I18n.t('activerecord.errors.messages.invalid')} (#{l(:setting_attachment_extensions_allowed)}: #{extensions})" @@ -978,14 +978,14 @@ module Redmine def after_save_custom_value(custom_field, custom_value) if custom_value.saved_change_to_value? if custom_value.value.present? - attachment = Attachment.where(:id => custom_value.value.to_s).first + attachment = Attachment.find_by(:id => custom_value.value.to_s) if attachment attachment.container = custom_value attachment.save! end end if custom_value.value_before_last_save.present? - attachment = Attachment.where(:id => custom_value.value_before_last_save.to_s).first + attachment = Attachment.find_by(:id => custom_value.value_before_last_save.to_s) if attachment attachment.destroy end |