Method: Dataset::RecordMethods#create_record

Defined in:
lib/dataset/session_binding.rb

#create_record(*args) ⇒ Object

Similar to old fashioned fixtures, this will do a direct database insert, without running any validations or preventing you from writing attr_protected attributes. Very nice for speed, but kind of a pain if you have complex structures or hard to keep right validations.

create_record :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 model will be a hash of the symbolic name.



98
99
100
# File 'lib/dataset/session_binding.rb', line 98

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