2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/enum_select_rails/action_view_ext.rb', line 2
def enum_select(record, options = {}, html_options = {})
pluralized = record.to_s.pluralize
klass = self.object.class
base = klass.send(pluralized)
i18n_method = "#{pluralized}_i18n".to_sym
if klass.methods.include? i18n_method
i18n = klass.send(i18n_method)
select record.to_sym, base.keys.map {|k| [i18n[k], k]}, options, html_options
else
select record.to_sym, base.keys.map {|k| [k, k]}, options, html_options
end
end
|