Module: ActionView::Helpers::ActiveRecordHelper
- Defined in:
- lib/gettext/rails.rb
Overview
:nodoc: all
Defined Under Namespace
Modules: L10n
Instance Method Summary collapse
-
#error_message(msg, count) ⇒ Object
:nodoc:.
-
#error_messages_for(*params) ⇒ Object
error_messages_for overrides original method with localization.
-
#error_messages_for_without_localize ⇒ Object
:nodoc:.
Instance Method Details
#error_message(msg, count) ⇒ Object
:nodoc:
396 397 398 |
# File 'lib/gettext/rails.rb', line 396 def (msg, count) #:nodoc: ngettext(msg, count) end |
#error_messages_for(*params) ⇒ Object
error_messages_for overrides original method with localization. And also it extends to be able to replace the title/explanation of the header of the error dialog. (Since 1.90) If you want to override these messages in the whole application,
use ActionView::Helpers::ActiveRecordHelper::L10n.set_error_message_(title|explanation) instead.
-
:message_title - the title of message. Use Nn_() to path the strings for singular/plural.
e.g. Nn_("%{num} error prohibited this %{record} from being saved",
“%num errors prohibited this %record from being saved”)
-
:message_explanation - the explanation of message
e.g. Nn_("There was a problem with the following field:", "There were %{num} problems with the following fields:")
412 413 414 415 416 417 418 419 420 421 422 |
# File 'lib/gettext/rails.rb', line 412 def (*params) = params.last.is_a?(Hash) ? params.pop.symbolize_keys : {} objects = params.collect {|object_name| instance_variable_get("@#{object_name}") }.compact object_names = params.dup count = objects.inject(0) {|sum, object| sum + object.errors.count } if count.zero? '' else L10n.(self, objects, object_names, count, ) end end |
#error_messages_for_without_localize ⇒ Object
:nodoc:
400 |
# File 'lib/gettext/rails.rb', line 400 alias |