Question: 1.Migration is a set of database instructions written in Ruby. The objective of migration is to change database state from one to another. True False

1.Migration is a set of database instructions written in Ruby. The objective of migration is to change database state from one to another.

True
False

2.Both of the following commands are equivalent in Rails 5.0+:

rake db:migrate

and

rails db:migrate
True
False

3.Assuming there is a model User with attributes of name and occupation, the create method call will create and save a new record into the database as follows:

user = User.create(name: "David", occupation: "Code Artist")

Alternatively the following code will also create a user record but not save it into the database:

user = User.new user.name = "David" user.occupation = "Code Artist"

Which of the following is the correct syntax for committing the user record to the database after the above code?

user.commit
user.done
user.save
None of the choices
user.persist

4.The following model code creates a Student model and maps it to a students table in the database:

class Students < Application Record end
True
False

5.Active Record allows you to validate the state of a model before it gets written into the database. One such method is save. What is the difference between the user.save! and user.savemethods?

None of the choices
user.save! is stricter in that it raises the exception ActiveRecord::RecordInvalid if validation fails.
Both user.save and user.save! are the same functionally
user.save is stricter in that it raises the exception ActiveRecord::RecordInvalid if validation fails.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!