I\'m new to rails and I don\'t understand the differences between the use of new+save methods and the create method.
def create
@item = Item.new(params[:
new creates the object but doesn't save it.
create creates the object and saves it, i.e. .new and .save
create! creates the object and tries to save it but raises an exception if validations fails, e.g. .new and .save!
One of confusion items is that the above is the actions that you take on an object, but similar names are also given to controller methods, especially in a RESTful environment. For example you have a create action.... which creates a new object, and then saves it and another create action which just does an object create.
If you're wondering "why create an object if I'm not going to save it?" consider this - the system 'tries' to save the object - but a validation prevents it and the user is asked to fill in more information on a form, perhaps required fields. One wants the object to still be created (.new) while this is going on and it will hold the values that have been assigned so far. However it doesn't actually get saved until it passes the validations as well.