Ruby on Rails Developer Certification — Questions and Answers
Question 1: Your Rails API is slow because email sending is blocking web requests. What is the correct architectural fix?
- Render the email in a partial to reduce view time
- Move email sending to an async job queue via Sidekiq or Active Job (Correct answer)
- Increase the number of Puma threads
- Cache email content with Rails.cache
Correct answer: Move email sending to an async job queue via Sidekiq or Active Job
Offloading email delivery to a background job keeps web requests fast and non-blocking.
Question 2: Which Rails helper method is used to test that a controller action redirects to a specific path?
- assert_redirected_to (Correct answer)
- assert_redirect
- assert_location
- assert_response :redirect
Correct answer: assert_redirected_to
`assert_redirected_to path` in Minitest controller tests verifies that the action responded with a redirect to the given URL.
Question 3: What is the role of `shared_examples` in RSpec?
- Run the same example in parallel across multiple threads
- Import examples from external gem specifications
- Share test data between different spec files
- Define reusable groups of examples that can be included in multiple describe blocks (Correct answer)
Correct answer: Define reusable groups of examples that can be included in multiple describe blocks
`shared_examples` lets you define a named group of examples once and include it with `it_behaves_like` wherever the same behavior must be verified.
Question 4: What is the default queue adapter in a Rails application when no background job gem is configured?
- :synchronous
- :inline
- :sidekiq
- :async (Correct answer)
Correct answer: :async
The :async adapter uses an in-process thread pool and is Rails' built-in default, though jobs are lost on server restart since they are not persisted.
Question 5: What is the purpose of a Rails `config/initializers/inflections.rb` research spike, and how should findings be documented?
- Document unexpected pluralization edge cases as failing tests before fixing them (Correct answer)
- Use it to benchmark string manipulation performance
- Log inflection rules to the database for future reference
- It is not research-worthy; inflections are trivial
Correct answer: Document unexpected pluralization edge cases as failing tests before fixing them
Documenting edge cases as failing tests before fixing them captures the discovered behavior as verifiable evidence for future developers.
Question 6: What Rails command enables or disables caching in the development environment?
- rails cache:toggle
- rails enable:caching
- rails dev:cache (Correct answer)
- rails config:cache
Correct answer: rails dev:cache
rails dev:cache toggles caching in development by creating or removing tmp/caching-dev.txt, which the development environment checks on startup.
Question 7: How should an Ruby on Rails professional respond to a compliance violation?
- Conceal it if minor
- Wait for an external audit to find it
- Blame the regulatory framework
- Report it promptly, investigate the root cause, and implement corrective actions (Correct answer)
Correct answer: Report it promptly, investigate the root cause, and implement corrective actions
This is fundamental to Ruby on Rails practice. Report it promptly, investigate the root cause, and implement corrective actions represents the professional standard for regulatory in the Ruby on Rails certification framework.
Question 8: Which tool is commonly used to measure Rails test coverage and identify untested code paths?
- Brakeman
- SimpleCov (Correct answer)
- Coveralls only
- RuboCop
Correct answer: SimpleCov
SimpleCov is the standard Ruby gem that instruments code and reports line/branch coverage percentages after your test suite runs.
Question 9: What class does ApplicationMailer inherit from in Ruby on Rails?
- ActionDispatch::Mailer
- ActionMailer::Controller
- ActionMailer::Base (Correct answer)
- ActionController::Base
Correct answer: ActionMailer::Base
ApplicationMailer inherits from ActionMailer::Base, which provides all email sending functionality including delivery methods, attachments, and header defaults.
Question 10: A Rails app must support both JSON API and HTML responses from the same controller action. Which Rails feature handles this cleanly?
- respond_to blocks with format.html and format.json (Correct answer)
- Middleware that inspects Accept headers and routes to different actions
- before_action with format checks
- Separate controllers for each format
Correct answer: respond_to blocks with format.html and format.json
respond_to blocks let a single action render different formats based on the client's Accept header or URL extension.
Question 11: What Rails command generates a new Active Job class called ProcessPayment?
- rails make job ProcessPayment
- rails generate job ProcessPayment (Correct answer)
- rails new job ProcessPayment
- rails create job ProcessPayment
Correct answer: rails generate job ProcessPayment
rails generate job (or rails g job) creates a new job file in app/jobs/ with a skeleton class and perform method.
Question 12: A stakeholder notices the Rails application error rate spiked overnight. What communication step should come first?
- Wait until fully resolved before communicating anything
- Deploy a hotfix immediately without informing anyone
- Blame the hosting provider
- Send a brief incident notification acknowledging the issue and its current status (Correct answer)
Correct answer: Send a brief incident notification acknowledging the issue and its current status
Proactive incident communication, even before a fix is ready, maintains stakeholder trust and sets resolution expectations.
Question 13: In Rails, what is the purpose of environment variables stored in `.env` files?
- Setting up test fixtures
- Configuring route namespaces
- Storing sensitive configuration like API keys outside of version control (Correct answer)
- Defining database schema
Correct answer: Storing sensitive configuration like API keys outside of version control
.env files (used with the dotenv gem) store sensitive credentials and environment-specific config that should not be committed to source control.
Question 14: What is the purpose of `belongs_to :article` in a Comment model?
- To validate that comments belong to an article class
- To create the articles table
- To define the inverse side of a has_many relationship, requiring an article_id foreign key (Correct answer)
- To generate a route for comments under articles
Correct answer: To define the inverse side of a has_many relationship, requiring an article_id foreign key
`belongs_to :article` declares the Comment as the child side of the relationship and expects an `article_id` column in the comments table.
Question 15: What does CSRF protection do in a Rails application?
- Prevents cross-site request forgery by validating an authenticity token with form submissions (Correct answer)
- Encrypts database passwords
- Blocks XSS attacks in views
- Sanitizes SQL queries
Correct answer: Prevents cross-site request forgery by validating an authenticity token with form submissions
Rails CSRF protection embeds a unique token in forms and validates it on non-GET requests to prevent malicious cross-site form submissions.
Question 16: Which Rails security feature should be enabled to comply with OWASP recommendations against session fixation attacks?
- protect_from_forgery
- reset_session after login (Correct answer)
- cookie_store encryption
- config.force_ssl
Correct answer: reset_session after login
Calling `reset_session` immediately after successful authentication issues a new session ID, preventing session fixation attacks.
Question 17: What testing framework does Rails include by default for unit and integration tests?
- RSpec
- Cucumber
- Minitest (Correct answer)
- Jasmine
Correct answer: Minitest
Rails ships with Minitest as its default testing framework, providing test cases for models, controllers, and integration scenarios.
Question 18: A Rails app allows users to search other users by name. A LIKE '%name%' query is slow on 2 million rows. Best fix?
- Cache the entire users table in Redis
- Use trigram indexes (pg_trgm) with GIN or GiST to support LIKE queries efficiently (Correct answer)
- Limit search results to 10 and paginate aggressively
- Add a B-tree index on users.name
Correct answer: Use trigram indexes (pg_trgm) with GIN or GiST to support LIKE queries efficiently
pg_trgm trigram indexes support leading-wildcard LIKE and ILIKE queries efficiently, which B-tree indexes cannot.
Question 19: How do you set a default 'from' email address for all mailers in ApplicationMailer?
- ActionMailer.from = 'noreply@app.com'
- config.action_mailer.default_from = 'noreply@app.com'
- default from: 'noreply@app.com' (Correct answer)
- set_default_from 'noreply@app.com'
Correct answer: default from: 'noreply@app.com'
The default class method inside ApplicationMailer accepts a hash of header defaults, including from, reply_to, and other email headers.
Question 20: What is the Rails Asset Pipeline used for?
- Concatenating, minifying, and serving CSS/JS assets efficiently (Correct answer)
- Routing API requests
- Handling background job processing
- Managing database migrations
Correct answer: Concatenating, minifying, and serving CSS/JS assets efficiently
The Asset Pipeline (Sprockets) concatenates and compresses JavaScript and CSS files, and handles asset fingerprinting for cache busting.
Question 21: What is the purpose of `VCR` gem in Rails testing?
- Profile slow database queries
- Capture browser screenshots during system tests
- Record and replay HTTP interactions to make tests deterministic (Correct answer)
- Mock ActiveRecord queries in unit tests
Correct answer: Record and replay HTTP interactions to make tests deterministic
VCR records real HTTP interactions into cassette files and replays them in future test runs, eliminating external network calls.
Question 22: When using Rails with a React frontend (API mode), which gem helps configure CORS headers?
- rack-rewrite
- rack-cors (Correct answer)
- rails-cors-headers
- actionpack-cors
Correct answer: rack-cors
The `rack-cors` gem adds Cross-Origin Resource Sharing headers to Rails API responses, allowing browsers to make cross-domain requests.
Question 23: Is it true that Ruby on Rails makes app development simpler?
- None of the above
- No Idea wrong
- No, It doesn't
- Yes, It does (Correct answer)
Correct answer: Yes, It does
Ruby on Rails is renowned for significantly simplifying and accelerating web application development. Its 'convention over configuration' philosophy, built-in scaffolding, Active Record ORM, and comprehensive set of libraries reduce the amount of boilerplate code developers need to write. This allows for rapid prototyping and efficient development of robust web applications, making the process much simpler.
Question 24: You're creating an ASP.NET MVC 4 application that stores data in an Oracle database. What session configuration options do you have that allow you to deploy your application on a web farm?
- InProc
- SQLServer and Custom session provide (Correct answer)
- SQLServer
- Custom session provide
Correct answer: SQLServer and Custom session provide
In an ASP.NET MVC web farm environment, session state needs to be shared across multiple servers. `InProc` (in-process) session state is server-specific and thus unsuitable, as requests might hit different servers. `SQLServer` session state stores data in a database, making it accessible to all servers. A `Custom session provider` offers flexibility to implement other shared storage mechanisms, both of which enable seamless session management in a web farm.
Question 25: What is `ActiveJob` in Rails used for?
- Scheduling database maintenance tasks
- Managing worker processes
- Monitoring application performance
- Providing a unified interface for declaring and running background jobs (Correct answer)
Correct answer: Providing a unified interface for declaring and running background jobs
ActiveJob is a framework for declaring background jobs and running them on various queuing backends like Sidekiq, Resque, or DelayedJob.
Ruby on Rails Developer Certification
Validates proficiency in building web applications with Ruby on Rails, covering MVC architecture, ActiveRecord, routing, testing, security, background jobs, caching, and API development.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds