Module: ActionView::Helpers::ActiveRecordHelper
- Defined in:
- lib/gettext_rails/action_view/active_record_helper.rb
Overview
:nodoc:
Defined Under Namespace
Modules: L10n
Instance Method Summary collapse
Instance Method Details
#error_messages_for_with_gettext_rails(*params) ⇒ Object
:nodoc:
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/gettext_rails/action_view/active_record_helper.rb', line 86 def (*params) #:nodoc: models = params.select{|param| ! param.kind_of? Hash} = params..symbolize_keys = (.has_key?(:header_message) || .has_key?(:message_title)) ? ([:header_message] || [:message_title]) : (:header) = (.has_key?(:message) || .has_key?(:message_explanation)) ? ([:message] || [:message_explanation]) : (:body) object = [:object] if object objects = [object].flatten else objects = params.collect {|object_name| instance_variable_get("@#{object_name}") }.compact end count = objects.inject(0) {|sum, object| sum + object.errors.count } [:object_name] ||= params.first normalized_model = [:object_name].to_s.gsub('_', ' ') #accept nil's as messages to hide message [:header_message] = L10n.(, normalized_model, count) [:message] = L10n.(, normalized_model, count) new_params = models << (*new_params) end |