Ruby on Rails Developer Certification โ Questions and Answers
Question 1: 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 2: Which Rails logger configuration reduces log verbosity in production while still capturing errors?
- config.log_tags = [:uuid, :remote_ip]
- config.log_level = :warn or :error (Correct answer)
- config.log_level = :debug
- config.logger = ActiveSupport::NullLogger
Correct answer: config.log_level = :warn or :error
Setting `log_level` to `:warn` or `:error` in production suppresses informational and debug output while still logging warnings and errors.
Question 3: A Rails app stores session data in cookies. Which risk does this introduce that server-side sessions avoid?
- Inability to store complex Ruby objects
- Automatic session expiry is not supported
- Client-side tampering if the secret_key_base is compromised (Correct answer)
- Slower response times due to serialization
Correct answer: Client-side tampering if the secret_key_base is compromised
Cookie-based sessions are signed with secret_key_base; if that key leaks, attackers can forge arbitrary session data.
Question 4: What is the file naming convention?
- Web page
- ActiveRecords
- Validate
- Underscores (Correct answer)
Correct answer: Underscores
Ruby on Rails follows specific naming conventions to maintain consistency and leverage 'convention over configuration.' For file names, especially for classes, modules, and views, the convention is to use `snake_case`, where words are separated by underscores. For example, a `UserProfile` model would be defined in `user_profile.rb`, and a `UsersController` would be in `users_controller.rb`.
Question 5: What is the purpose of `config.cache_classes = false` in the Rails development environment?
- It turns off class-level memoization in models
- It prevents ActiveRecord from caching SQL query results
- It disables fragment caching to show live data
- It reloads application code on each request so changes take effect without restarting (Correct answer)
Correct answer: It reloads application code on each request so changes take effect without restarting
With `cache_classes: false`, Rails reloads changed Ruby files on every request, enabling hot-reload during development.
Question 6: Which background job processing gem is most widely used with Ruby on Rails in production?
- Sucker Punch
- Delayed::Job
- Sidekiq (Correct answer)
- Resque
Correct answer: Sidekiq
Sidekiq is the most popular Rails background job processor, using Redis for job persistence and multi-threaded workers for high throughput.
Question 7: A Rails app must implement 'legitimate interest' documentation per GDPR Article 6(1)(f). Where in a Rails codebase is this best recorded programmatically?
- In model validations as comments
- In the Gemfile as gem annotations
- As structured metadata in a DataProcessingActivity concern or registry (Correct answer)
- In config/application.rb as constants
Correct answer: As structured metadata in a DataProcessingActivity concern or registry
A dedicated `DataProcessingActivity` concern or registry class documents each processing purpose, legal basis, and data categories in a machine-readable, auditable way.
Question 8: The representation of a resource is referred to as...
- Ruby make
- Web page (Correct answer)
- Action pack
- Camel case
Correct answer: Web page
In the context of web development and RESTful principles often followed by frameworks like Ruby on Rails, a 'resource' (such as a user or a product) is typically represented to the user through a web page. This web page displays the resource's data and often provides interfaces for interacting with it, such as editing or deleting. It serves as the visual and interactive representation of the underlying data.
Question 9: Which Rails environment is used when running `rails test` by default?
- staging
- test (Correct answer)
- production
- development
Correct answer: test
The test environment uses a separate database and configuration to isolate test runs from development and production data.
Question 10: Which Rails view helper method is used to wrap content in a fragment cache block?
- cache do (Correct answer)
- fragment_cache do
- cache_block do
- cached do
Correct answer: cache do
The cache helper in Rails views wraps a block of ERB content, using the provided key or object to generate a cache key and store the rendered output.
Question 11: In FactoryBot, what is a `trait` used for?
- Define optional attribute overrides that can be mixed into factory instances (Correct answer)
- Create a separate factory that inherits all parent attributes
- Register a factory under an alternate name
- Validate factory attributes before building
Correct answer: Define optional attribute overrides that can be mixed into factory instances
Traits group related attribute overrides (e.g., `trait :admin`) that can be applied selectively when building instances with `create(:user, :admin)`.
Question 12: Which Rails Active Storage configuration is required when storing medical images to comply with HIPAA's encryption at rest requirement?
- Setting content_disposition: :inline
- Using S3 service with server_side_encryption: 'aws:kms' (Correct answer)
- config.active_storage.service = :local
- config.active_storage.variable_content_types whitelist
Correct answer: Using S3 service with server_side_encryption: 'aws:kms'
Configuring Active Storage's S3 service with `server_side_encryption: 'aws:kms'` ensures all uploaded files are encrypted at rest using AWS KMS, satisfying HIPAA.
Question 13: Which method executes an Active Job immediately in the current thread without queuing it?
- MyJob.perform_now (Correct answer)
- MyJob.dispatch_now
- MyJob.execute_now
- MyJob.run_now
Correct answer: MyJob.perform_now
perform_now executes the job synchronously in the current thread, bypassing the queue adapter โ useful for testing and for immediate execution requirements.
Question 14: In Rails, what is the purpose of environment variables stored in `.env` files?
- Defining database schema
- Storing sensitive configuration like API keys outside of version control (Correct answer)
- Setting up test fixtures
- Configuring route namespaces
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 15: What is the name of the online application that merges data and services from various sources on the internet?
- an action
- a fixture
- form_for
- mashup (Correct answer)
Correct answer: mashup
A 'mashup' is a web application that combines data, presentation, or functionality from two or more external sources to create a new, integrated service. This often involves using APIs to pull information from different websites or services and then presenting it together in a novel way. A common example is combining mapping data with real estate listings.
Question 16: What information does cache_key_with_version return for an ActiveRecord model instance?
- The database table name and the record's primary key only
- A UUID generated at the time the cache entry is written
- The MD5 hash of all the model's serialized attributes
- A string combining the model name, record ID, and updated_at timestamp (Correct answer)
Correct answer: A string combining the model name, record ID, and updated_at timestamp
cache_key_with_version returns a string like 'articles/5-20240101120000000000' that automatically invalidates the cache when the record is updated, since updated_at changes on every save.
Question 17: Your Rails API is slow because email sending is blocking web requests. What is the correct architectural fix?
- Move email sending to an async job queue via Sidekiq or Active Job (Correct answer)
- Render the email in a partial to reduce view time
- 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 18: In Rails, what does `ActionMailer` provide?
- A background job for processing emails
- An IMAP client for reading emails
- A framework for composing and sending email from the Rails application (Correct answer)
- A mail server for production
Correct answer: A framework for composing and sending email from the Rails application
ActionMailer provides a model-like interface for composing email using templates and sending via a configured mail delivery method.
Question 19: Which Rails mechanism helps mitigate mass assignment vulnerabilities introduced before Strong Parameters?
- Content Security Policy headers
- CSRF token validation
- before_action callbacks
- attr_accessible / attr_protected in the model (Correct answer)
Correct answer: attr_accessible / attr_protected in the model
attr_accessible and attr_protected were the Rails 3 approach to whitelisting/blacklisting mass-assignable attributes before Strong Parameters replaced them in Rails 4.
Question 20: What file in Rails stores the database connection configuration?
- db/connection.rb
- config/application.rb
- config/database.yml (Correct answer)
- config/secrets.yml
Correct answer: config/database.yml
config/database.yml defines database adapter, host, credentials, and database name for development, test, and production environments.
Question 21: What is the default cache store in a Rails application without any explicit cache configuration?
- :memory_store (Correct answer)
- :mem_cache_store
- :null_store
- :file_store
Correct answer: :memory_store
Rails defaults to :memory_store, which stores cached data in a hash within the Ruby process โ data is not shared between processes or persisted across restarts.
Question 22: Which method enqueues an Active Job for asynchronous background processing?
- run_async
- perform_background
- perform_later (Correct answer)
- enqueue_later
Correct answer: perform_later
perform_later serializes the job arguments and enqueues the job to the configured queue adapter for asynchronous background execution.
Question 23: What gem is most commonly used for authentication in Rails applications?
- Devise (Correct answer)
- Cancancan
- Pundit
- OmniAuth
Correct answer: Devise
Devise is the most widely used Rails authentication gem, providing sign-up, sign-in, password reset, and session management out of the box.
Question 24: Which approach provides the strongest evidence when deciding whether to extract a Rails service object from a fat model?
- Checking if the model file exceeds 200 lines
- Measuring test execution time and cyclomatic complexity before and after (Correct answer)
- Following the single responsibility principle by instinct
- Asking the team for opinions
Correct answer: Measuring test execution time and cyclomatic complexity before and after
Measuring cyclomatic complexity and test suite speed before and after extraction provides objective evidence that the refactor improved maintainability.
Question 25: In Minitest, which assertion checks that two objects are the same object instance (identity, not equality)?
- assert_equal
- assert_identical
- assert_object_id
- assert_same (Correct answer)
Correct answer: assert_same
`assert_same` uses `equal?` (object identity via `object_id`) rather than `==` to verify two variables reference the exact same object.
Question 26: What does CSRF protection do in a Rails application?
- Prevents cross-site request forgery by validating an authenticity token with form submissions (Correct answer)
- Blocks XSS attacks in views
- Sanitizes SQL queries
- Encrypts database passwords
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 27: What is the `rails credentials` system used for in modern Rails?
- Securely storing encrypted application secrets like API keys (Correct answer)
- Defining database user permissions
- Managing user login credentials in the database
- Storing SSL certificates
Correct answer: Securely storing encrypted application secrets like API keys
Rails credentials (config/credentials.yml.enc) stores encrypted secrets decrypted at runtime using a master key, replacing the old secrets.yml approach.
Question 28: How should an Ruby on Rails professional handle an outcome that differs from expectations?
- Ignore the discrepancy
- Blame external factors
- Repeat the same approach
- Analyze contributing factors, document findings, and adjust approach based on lessons learned (Correct answer)
Correct answer: Analyze contributing factors, document findings, and adjust approach based on lessons learned
This is fundamental to Ruby on Rails practice. Analyze contributing factors, document findings, and adjust approach based on lessons learned represents the professional standard for practical in the Ruby on Rails certification framework.
Question 29: Which approach correctly stubs an instance method on a specific object in RSpec without affecting other instances?
- stub_method(instance, :method_name, value)
- allow(instance).to receive(:method_name).and_return(value) (Correct answer)
- RSpec.stub_on(instance, :method_name, value)
- instance.stub(:method_name) { value }
Correct answer: allow(instance).to receive(:method_name).and_return(value)
`allow(obj).to receive` sets up a message expectation on that specific instance only, leaving other instances of the class unaffected.
Question 30: What is the purpose of Rails fixtures in testing?
- To provide predefined test data loaded into the test database (Correct answer)
- To configure the test environment settings
- To define CSS styles for test views
- To mock external API responses
Correct answer: To provide predefined test data loaded into the test database
Fixtures are YAML files in test/fixtures/ that define sample records loaded into the test database before each test run.
Question 31: A healthcare Rails app must log all access to patient records per HIPAA's audit control requirement (ยง164.312(b)). Which approach is most appropriate?
- Rails.logger.info in every controller action
- ActiveSupport::Notifications subscriber on ActiveRecord queries
- after_action callback writing to a separate audit_logs table (Correct answer)
- Database-level audit trigger via PostgreSQL
Correct answer: after_action callback writing to a separate audit_logs table
An `after_action` callback writing to a dedicated `audit_logs` table captures who accessed which patient record with timestamps, satisfying HIPAA ยง164.312(b).
Question 32: Which tool is commonly used for root cause analysis in Ruby on Rails quality management?
- Fishbone (Ishikawa) diagram to identify contributing factors systematically (Correct answer)
- Customer surveys only
- Random sampling
- Profit analysis
Correct answer: Fishbone (Ishikawa) diagram to identify contributing factors systematically
This is fundamental to Ruby on Rails practice. Fishbone (Ishikawa) diagram to identify contributing factors systematically represents the professional standard for quality in the Ruby on Rails certification framework.
Question 33: What Rails command generates a new Active Job class called ProcessPayment?
- rails new job ProcessPayment
- rails make job ProcessPayment
- rails generate job ProcessPayment (Correct answer)
- 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 34: Which risk does enabling `config.assets.compile = true` in a Rails production environment introduce?
- Loss of asset fingerprinting causing cache invalidation failures
- Breaking of Webpacker JavaScript module resolution
- Permanent disabling of the Turbo Drive page-transition cache
- Increased CPU/memory load and potential DoS from on-demand asset compilation per request (Correct answer)
Correct answer: Increased CPU/memory load and potential DoS from on-demand asset compilation per request
Live asset compilation is expensive; if triggered per request under load, it can exhaust CPU and memory, effectively causing a denial of service.
Question 35: What does `rails db:migrate` do?
- Seeds the database with test data
- Rolls back all migrations
- Exports the database to a file
- Runs all pending migration files to update the database schema (Correct answer)
Correct answer: Runs all pending migration files to update the database schema
`rails db:migrate` executes all pending migration files in chronological order to apply schema changes to the database.
Question 36: A stakeholder notices the Rails application error rate spiked overnight. What communication step should come first?
- Send a brief incident notification acknowledging the issue and its current status (Correct answer)
- Deploy a hotfix immediately without informing anyone
- Blame the hosting provider
- Wait until fully resolved before communicating anything
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 37: What is the default queue adapter in a Rails application when no background job gem is configured?
- :synchronous
- :sidekiq
- :inline
- :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 38: Which Rails feature helps comply with GDPR's requirement to document and disclose third-party data processors in your data processing agreements?
- Initializer files listing third-party gems and their data access
- ActiveSupport::Notifications instrumentation (Correct answer)
- Rack middleware stack inspection
- ApplicationRecord concerns
Correct answer: ActiveSupport::Notifications instrumentation
ActiveSupport::Notifications can instrument third-party service calls, providing an audit trail of what external processors received your users' data.
Question 39: What does the retry_on class method configure in an Active Job?
- Immediate synchronous retry on any exception
- Re-runs all previously failed jobs stored in the database
- Restarts all stopped workers in the queue backend
- Automatic retries for specified exceptions with configurable wait and attempt limits (Correct answer)
Correct answer: Automatic retries for specified exceptions with configurable wait and attempt limits
retry_on specifies which exception classes should trigger automatic retries, with configurable wait intervals (fixed or exponential) and maximum attempt counts.
Question 40: What is the purpose of a Rails 'system test'?
- End-to-end browser testing that simulates real user interactions (Correct answer)
- Testing API JSON responses
- Testing database migrations
- Unit testing model validations
Correct answer: End-to-end browser testing that simulates real user interactions
System tests in Rails use a real browser (via Capybara) to test full user workflows from clicking links to form submissions.
Question 41: Which Rails command generates a new database migration file?
- rails db:schema
- rails migrate:create
- rails db:new
- rails generate migration AddTitleToArticles (Correct answer)
Correct answer: rails generate migration AddTitleToArticles
`rails generate migration MigrationName` creates a timestamped migration file in db/migrate/ for database schema changes.
Question 42: In Rails routing, what does `root 'pages#home'` specify?
- The default route for the application's root URL '/' (Correct answer)
- The URL for the home controller
- A named route called 'root'
- The admin root path
Correct answer: The default route for the application's root URL '/'
`root 'pages#home'` maps the root URL (/) to the `home` action in the `PagesController`.
Question 43: Which Rails mechanism helps communicate database migration risks to the team before deployment?
- Adding detailed comments to the migration file describing reversibility and data impact (Correct answer)
- Using schema.rb as the only migration reference
- Deleting old migrations to reduce confusion
- rails db:rollback run in production
Correct answer: Adding detailed comments to the migration file describing reversibility and data impact
Annotating migrations with reversibility notes and data impact warnings helps reviewers assess deployment risk before it reaches production.
Question 44: What is the role of the `Gemfile.lock` in a Rails project?
- Preventing new gems from being added
- Locking the Rails version globally
- Recording exact gem versions installed so all environments use identical dependencies (Correct answer)
- Encrypting gem source URLs
Correct answer: Recording exact gem versions installed so all environments use identical dependencies
Gemfile.lock records the exact resolved versions of all gems and their dependencies, ensuring consistent installs across all environments.
Question 45: How do you protect a Rails API endpoint so only authenticated users can access it?
- By using `secure_action` in routes.rb
- By setting `private: true` on the action
- By calling `before_action :authenticate_user!` or a custom auth callback (Correct answer)
- By adding SSL to the route
Correct answer: By calling `before_action :authenticate_user!` or a custom auth callback
`before_action :authenticate_user!` (Devise) or a custom `before_action` method runs before the action to check authentication.
Question 46: For CCPA compliance, a Rails app must honor 'Do Not Sell My Personal Information' requests. Which architecture pattern best implements this?
- A boolean do_not_sell flag on the User model with scoped queries excluding flagged users from analytics exports (Correct answer)
- Encrypting user data with a user-held key
- Deleting all user records upon request
- Anonymizing all fields to 'REDACTED'
Correct answer: A boolean do_not_sell flag on the User model with scoped queries excluding flagged users from analytics exports
A `do_not_sell` flag allows the app to exclude opted-out users from third-party data sharing while retaining their account, matching CCPA's scope.
Question 47: What does `rails generate scaffold Post title:string body:text` create?
- Model, migration, controller, views, and routes for full CRUD (Correct answer)
- Only the model and migration
- A database backup of the posts table
- Only the routes and controller
Correct answer: Model, migration, controller, views, and routes for full CRUD
The scaffold generator creates the full CRUD stack: model, migration, controller with all RESTful actions, views, and routes in one command.
Question 48: What is Strong Parameters in Rails and why is it used?
- A method for validating parameter types
- A configuration for stricter SQL queries
- A way to define required database columns
- A security feature that requires explicitly permitting which parameters can be mass-assigned (Correct answer)
Correct answer: A security feature that requires explicitly permitting which parameters can be mass-assigned
Strong Parameters (via `params.require(...).permit(...)`) prevents mass-assignment vulnerabilities by whitelisting which request parameters can update model attributes.
Question 49: How should Ruby on Rails professionals evaluate new technology tools?
- Wait until competitors adopt first
- Assess functionality, reliability, security, cost-effectiveness, and alignment with professional needs (Correct answer)
- Adopt all new technology immediately
- Avoid all new technology
Correct answer: Assess functionality, reliability, security, cost-effectiveness, and alignment with professional needs
This is fundamental to Ruby on Rails practice. Assess functionality, reliability, security, cost-effectiveness, and alignment with professional needs represents the professional standard for technology in the Ruby on Rails certification framework.
Question 50: Which method is used for low-level caching to read or compute-and-store arbitrary data in Rails?
- cache_store.get_or_set
- ApplicationCache.read
- Rails.cache.fetch (Correct answer)
- Rails.cache.store
Correct answer: Rails.cache.fetch
Rails.cache.fetch checks the cache for a key, and on a miss executes the provided block to generate the value, stores it, and returns the result.
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