method

create

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.

3Notes

yijisoo

sfusion · Dec 13, 20091 thank

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

e.g.

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

is the same as

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

What's difference between create and new?

yijisoo · Dec 13, 2009

What's difference between create and new?

Where this method moved to

roryokane · May 25, 2016

After v3.1.0, this method moved to ActiveRecord::Persistence::ClassMethods#create .