instance method
init_with
Ruby on Rails 3.1.12
Since v3.0.20 Last seen in v3.2.22.5Signature
init_with(coder)
Initialize an empty model object from coder. coder must contain the attributes necessary for initializing an empty model object. For example:
class Post < ActiveRecord::Base end post = Post.allocate post.init_with('attributes' => { 'title' => 'hello world' }) post.title # => 'hello world'
Parameters
-
coderreq
Source
# File activerecord/lib/active_record/base.rb, line 1610
def init_with(coder)
@attributes = coder['attributes']
@relation = nil
set_serialized_attributes
@attributes_cache, @previously_changed, @changed_attributes = {}, {}, {}
@association_cache = {}
@aggregation_cache = {}
@readonly = @destroyed = @marked_for_destruction = false
@new_record = false
run_callbacks :find
run_callbacks :initialize
self
end
Defined in activerecord/lib/active_record/base.rb line 1610
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Base