The Model.new method creates an instance of the nil model, and the Model.create method further attempts to store it directly in the database.
Model.create method creates an object (or several objects) and stores it in the database if validations pass. The resulting object returns whether the object was successfully stored in the database or not.
object = Model.create does not need any object.save method to store values ββin the database.
In the Model.new method Model.new new objects can be created as empty (do not pass the constructive parameter)
In Model.new(params[:params]) pre-configured with attributes, but not yet stored in the database (pass a hash with the key names corresponding to the column names of the linked tables).
After object = Model.new we need to save the object object.save
Debadatt
source share