Ruby on Rails Test

Exam Type: Ruby on Rails MCQ Skill Test
Questions Type: Multiple Choice Questions
Total Questions: 27
Time Limit: 30 Minutes
Last Update July, 2025

Pass Ruby on Rails Exam

75%
Total time

1 minute 2 seconds

Total time

1 correct answers

Total time

6 incorrect answers

Total time

6 not attempted

Start

Ruby On Rails Quiz

Question 1 of 27
30:00

In the following code, the logout message will not appear on the login template because of a bug in the code. What is the bug?

class AccessController < ActionController::Base


  def destroy

  session[:admin_id] = nil

  flash[:notice] = "You have been logged out."

  render('login')

  end

 end

  1. An instance variable should be used for flash[:notice].
  2. The string assigned to flash[:notice] will not be available until the next browser request.
  3. The previous value of flash[:notice] will not be cleared automatically.
  4. This is an invalid syntax to use to assign values to flash[:notice].
     

Which statement best explains the purpose of `includes(:address)` in the following code?
@portfolios = Portfolio.includes(:image).limit(20)

 @portfolios.each do |portfolio|
  puts portfolio.image.caption
 end

  1. It enables the code to access the image instance related to each portfolio instance.
  2. It joins the two tables into a single database query.
  3. It will execute 2 database queries instead of 21 database queries.
  4. It preloads the image files using asset pipeline.
     

What code could be used in a template to output "Ruby" in the response to the browser?

  1. <= print "Ruby" >
  2. <? echo "Ruby" ?>
  3. <%= "Ruby" %>
  4. <% puts "Ruby" %>
     

Where would the following code most likely be found in a Rails project? scope :active, lambda { where(:active => true) }

Within a Rails controller, which code will prevent the parent controller’s before_action :get_feature from running?

Which statement correctly describes a difference between the form helper methods form_tag and form_for?

What is before_action (formerly known as before_filter)?

Which are standard REST HTTP verbs?

Q7. Which choice includes standard REST HTTP verbs?

Which ActiveRecord query prevents an SQL Injection?

Which example shows a type of variable that enables the rendered template to access its value?

Which of the following statements about migrations is FALSE?

Which example below shows an INCORRECT way to render a partial?

Which choice best describes the expected value of @result? @result = article.first.tags.build(name: ‘urgen’)

The asset pipeline in Ruby on Rails helps manage JavaScript and CSS assets. Which choice is NOT a feature of asset pipeline?

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

Which statement best describes what the render method does?

Which choice correctly describes a difference between the form helper methods form_tag and form_for?

What keyword is used in a layout to identify a section where content from the view should be inserted?

Which is NOT a valid Rails route?

If the Rails asset pipeline is being used to serve JavaScript files, how would you include a link to one of those JavaScript files in a view?

In Rails, how would you cache a partial template that is rendered?

Which statement is TRUE?

Which of the following choices shows the correct way to assign a value to the session?

Which technique would NOT be useful to share common attributes and behaviors between two ActiveRecord models?

What is a standard prerequisite for implementing Single Table Inheritance (STI)?

Previous versions of Ruby on Rails required developers to explicitly call ERB's html_escape method on strings to make them safe for use in templates. Current versions escape all strings by default. Which command tells a template NOT to escape a string?

Ruby on Rails Test Explained

© 2025 Skill Test Answer. All Rights Reserved