Ruby on Rails Developer Question:
Tell us what’s the difference between new, save and create?
Answer:
new – makes a new object but doesn’t save it to the database
save – saves the model. If the model is new a record gets created in the database, otherwise the existing record gets updated.
create – makes a new object and saves it to the database in one go
save – saves the model. If the model is new a record gets created in the database, otherwise the existing record gets updated.
create – makes a new object and saves it to the database in one go
Previous Question | Next Question |
Tell us what are benefits of using Active Record as opposed to raw SQL queries? | Tell us what is the use of super function in Ruby on Rails? |