Actions
Feature #22383
closedSupport of default Active Record (I18n) transliteration paths
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Fixed
Description
For now, in 10-patches.rb we have a redefinition of method human_attribute_name. But default (plain without hierarchy) Redmine style of transliterations are not convinient for some reasons, especially in big projects. So, my proposal is follows: enable ActiveRecord behaviour for finding transliterations path and add in list of search paths custom one from Redmine. Here is a worked snippet of code:
def self.human_attribute_name(attr, options = {})
prepared_attr = attr.to_s.sub(/_id$/, '').sub(/^.+\./, '')
redmine_default =
[
:"field_#{name.underscore.gsub('/', '_')}_#{prepared_attr}",
:"field_#{prepared_attr}"
]
if options[:default].present?
options[:default] = [options[:default]] unless options[:default].is_a? Array
options[:default].unshift redmine_default
else
options[:default] = redmine_default
end
super
end
In this case we obtain follows chain of search paths:
- default AR paths (for example: activerecord.attributes.model_name.field_name)
- default Redmine paths (for example: field_content)
- user specified paths (specified in :default key from options attribute)
attribute.humanize
(from default human_attribute_name from ActiveModel)
Related issues
Updated by Jean-Philippe Lang over 8 years ago
- Status changed from New to Closed
- Assignee set to Jean-Philippe Lang
- Resolution set to Fixed
Change committed, thanks.
Updated by Go MAEDA over 6 years ago
- Related to Feature #26618: Support of default ActiveRecord I18n scopes in LabelledFormBuilder added
Actions