method
create
v1.1.6 -
Show latest stable
- Class:
ActiveRecord::Base
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
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?
What's difference between create and new?
Where this method moved to
After v3.1.0, this method moved to ActiveRecord::Persistence::ClassMethods#create .