Method: Dataset::RecordMethods#create_model

Defined in:
lib/dataset/session_binding.rb

#create_model(*args) ⇒ Object

This will instantiate your model class and assign each attribute WITHOUT using mass assignment. Validations will be run. Very nice for complex structures or hard to keep right validations, but potentially a bit slower, since it runs through all that ActiveRecord code.

create_model :type, :symbolic_name, :attr1 => 'value', :attr2 => 'value', :etc => 'etc'

The symbolic_name is an optional parameter. You may replace type with an ActiveRecord::Base subclass or anything that works with:

to_s.classify.constantize

The id of the record will be kept from the instance that is saved.



116
117
118
# File 'lib/dataset/session_binding.rb', line 116

def create_model(*args)
  dataset_session_binding.create_model(*args)
end