Ruby on Rails MCQ Quiz Hub

Ruby on Rails Multiple choice Questions Set 3

Choose a topic to test your knowledge and improve your Ruby on Rails skills

What command do you run to undo the last 5 migrations





✅ Correct Answer: 1

A global variable has a name beginning with:





✅ Correct Answer: 1

What gets returned by: [1, [2, 3,[4, 5]]].flatten





✅ Correct Answer: 1

How can you create a new Rails project?





✅ Correct Answer: 1

Which of the following will delete the key-value 1 from array: "big_data"





✅ Correct Answer: 3

What is the use of $ in Ruby?





✅ Correct Answer: 2

Which code sample will skip running the login_required "before" filter on the get_posts controller action?





✅ Correct Answer: 3

Which is NOT a default Rails environment?





✅ Correct Answer: 1

What is a Gem?





✅ Correct Answer: 2

Which extension is default for views html templates?





✅ Correct Answer: 1

In the MVC pattern:





✅ Correct Answer: 3

What is the command to install Rails?





✅ Correct Answer: 3

What command do you run to create your database?





✅ Correct Answer: 3

What command do you run to drop your database?





✅ Correct Answer: 2

How would you declare an Instance Variable?





✅ Correct Answer: 2

Ruby uses:





✅ Correct Answer: 2

What command do you run to update your database?





✅ Correct Answer: 2

Migrations...





✅ Correct Answer: 4

What is the preferred method of validating that the name has been set?





✅ Correct Answer: 1

Which of the following will interpolate within a string with the variable named 'monster'?





✅ Correct Answer: 2

What is the output of the following ? s="foo" * 2 puts s





✅ Correct Answer: 2

What ORM does Ruby on Rails use by default?





✅ Correct Answer: 4

What is a typical file extension found in the app/controllers directory





✅ Correct Answer: 3

Which of these is not a standard directory in a Rails application?





✅ Correct Answer: 4

The recommended directory in which to place your app's javascript files is:





✅ Correct Answer: 1

Which files is used to specify any default data that should be loaded into the application's database, when it is first setup?





✅ Correct Answer: 4

What is the default value for a global variable (before initialization)?





✅ Correct Answer: 2

Which of the following prints the "Hello WORLD!" output with a new line?





✅ Correct Answer: 1

How do you create a new user object with the name david and save it to the database?





✅ Correct Answer: 2

Which of these does NOT correctly return the version of Ruby?





✅ Correct Answer: 1

If you want the /person url to map to your dog controller and show method, what do you add to your routes?





✅ Correct Answer: 1

What is the use of the 'defined?' method?





✅ Correct Answer: 3

Which of these javascript frameworks became the default with the release of Rails 3.1?





✅ Correct Answer: 2

When Ruby methods add an exclamation point at the end of their name (such as sort!), what does it typically indicate?





✅ Correct Answer: 4

Which Rails helper would you use in the application view to protect against CSRF (Cross-Site Request Forgery) attacks?





✅ Correct Answer: 3

In a Rails controller, what does the code params.permit(:name, :sku) do?





✅ Correct Answer: 2

Review the code below. Which Ruby operator should be used to fill in the blank so that the sort method executes properly? [5,8,2,6,1,3].sort {|v1,v2| v1 ___ v2}





✅ Correct Answer: 3

Which statement about ActiveRecord models is true?





✅ Correct Answer: 3

Which choice best describes the expected value of @result? @result = Article.first.tags.build(name: 'Urgent')





✅ Correct Answer: 2

Which part of the Rails framework is primarily responsible for making decisions about how to respond to a browser request?





✅ Correct Answer: 2

If User is an ActiveRecord class, which choice would be expected to return an array?





✅ Correct Answer: 1

Which choice is not a valid Rails route?





✅ Correct Answer: 1

Given a table of blog_posts and a related table of comments (comments made on each blog post), which ActiveRecord query will retrieve all blog posts with comments created during @range?





✅ Correct Answer: 1

Which choice is an incorrect way to render a partial?





✅ Correct Answer: 3