instance method
init_with
Ruby on Rails 3.0.20
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 1457
def init_with(coder)
@attributes = coder['attributes']
@attributes_cache, @previously_changed, @changed_attributes = {}, {}, {}
@new_record = @readonly = @destroyed = @marked_for_destruction = false
_run_find_callbacks
_run_initialize_callbacks
end
Defined in activerecord/lib/active_record/base.rb line 1457
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Base