Active Model Conversions

Handles default conversions: to_model, to_key and to_param.

Example

Let’s take for example this non persisted object.

  class ContactMessage
    include ActiveModel::Conversion

    # ContactMessage are never persisted in the DB
    def persisted?
      false
    end
  end

  cm = ContactMessage.new
  cm.to_model == self # => true
  cm.to_key           # => nil
  cm.to_param         # => nil
Show files where this module is defined (1 file)
Register or log in to add new notes.