HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/gems/ruby-2.6.8/doc/activemodel-6.1.4.1/ri/ActiveModel/Model/cdesc-Model.ri
U:RDoc::NormalModule[iI"
Model:ETI"ActiveModel::Model;T0o:RDoc::Markup::Document:@parts[o;;[S:RDoc::Markup::Heading:
leveli:	textI" Active \Model \Basic \Model;To:RDoc::Markup::BlankLineo:RDoc::Markup::Paragraph;[
I"DIncludes the required interface for an object to interact with ;TI"HAction Pack and Action View, using different Active Model modules. ;TI"JIt includes model name introspections, conversions, translations and ;TI"Nvalidations. Besides that, it allows you to initialize the object with a ;TI"=hash of attributes, pretty much like Active Record does.;T@o;
;[I"'A minimal implementation could be:;T@o:RDoc::Markup::Verbatim;[
I"class Person
;TI""  include ActiveModel::Model
;TI"!  attr_accessor :name, :age
;TI"	end
;TI"
;TI"1person = Person.new(name: 'bob', age: '18')
;TI"person.name # => "bob"
;TI"person.age  # => "18"
;T:@format0o;
;[I"WNote that, by default, <tt>ActiveModel::Model</tt> implements <tt>persisted?</tt> ;TI"Pto return +false+, which is the most common case. You may want to override ;TI"7it in your class to simulate a different scenario:;T@o;;[I"class Person
;TI""  include ActiveModel::Model
;TI"   attr_accessor :id, :name
;TI"
;TI"  def persisted?
;TI"    self.id == 1
;TI"  end
;TI"	end
;TI"
;TI"-person = Person.new(id: 1, name: 'bob')
;TI"!person.persisted? # => true
;T;0o;
;[I"PAlso, if for some reason you need to run code on <tt>initialize</tt>, make ;TI"Msure you call +super+ if you want the attributes hash initialization to ;TI"happen.;T@o;;[I"class Person
;TI""  include ActiveModel::Model
;TI"&  attr_accessor :id, :name, :omg
;TI"
;TI"%  def initialize(attributes={})
;TI"    super
;TI"    @omg ||= true
;TI"  end
;TI"	end
;TI"
;TI"-person = Person.new(id: 1, name: 'bob')
;TI"person.omg # => true
;T;0o;
;[I"NFor more detailed information on other functionalities available, please ;TI"Krefer to the specific modules included in <tt>ActiveModel::Model</tt> ;TI"(see below).;T:
@fileI"lib/active_model/model.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[[[[I"%ActiveModel::AttributeAssignment;To;;[;@N;0I"lib/active_model/model.rb;T[I"ActiveModel::Validations;To;;[;@N;0@V[I"ActiveModel::Conversion;To;;[;@N;0@V[[I"
class;T[[:public[[I"new;T@V[:protected[[:private[[I"
instance;T[[;[[I"persisted?;T@V[;[[;[[[I"ActiveSupport::Concern;To;;[;@N;0@V[I"ActiveModel::Naming;To;;[;@N;0@V[I"ActiveModel::Translation;To;;[;@N;0@V[U:RDoc::Context::Section[i0o;;[;0;0[@NI"ActiveModel;TcRDoc::NormalModule