instance method get

Ruby on Rails 5.0.7.2

Last seen in v5.0.7.2

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.11.3 v5.0.7.2

Signature

get(key)

Get messages for key.

person.errors.messages   # => {:name=>["cannot be nil"]}
person.errors.get(:name) # => ["cannot be nil"]
person.errors.get(:age)  # => []

Parameters

key req
Source
# File activemodel/lib/active_model/errors.rb, line 123
    def get(key)
      ActiveSupport::Deprecation.warn(<<-MESSAGE.squish)
        ActiveModel::Errors#get is deprecated and will be removed in Rails 5.1.

        To achieve the same use model.errors[:#{key}].
      MESSAGE

      messages[key]
    end

Defined in activemodel/lib/active_model/errors.rb line 123 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveModel::Errors

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close