create(attributes = nil) public

Creates an object, instantly saves it as a record (if the validation permits it), and returns it. If the save fails under validations, the unsaved object is still returned.

Show source
Register or log in to add new notes.
December 13, 2009
1 thank


create generates the object and saves. new only generates the object.


o = Object.new(:foo => 'bar')

is the same as

o = Object.create(:foo => 'bar')
December 13, 2009
0 thanks

What's difference between create and new?

What’s difference between create and new?