1. What is Ruby on Rails?
A web application framework written in Ruby that follows MVC architecture and convention over configuration.
2. Explain MVC in Rails.
-
Model: manages data and logic
-
View: presentation layer
-
Controller: handles requests and responses
3. What are migrations in Rails?
Ruby files that alter the database schema.
Β Rails uses ActiveRecord::Migration to version changes.
4. What is the difference between has_one, has_many, and belongs_to?
- has_one: one-to-one
- has_many: one-to-many
- belongs_to: foreign key ownership
5. What are strong parameters?
A Rails mechanism to prevent mass assignment vulnerabilities. Used with params.require(...).permit(...)
6. What is the asset pipeline?
System for managing and compiling CSS, JS, and images in Rails.
7. What are callbacks in ActiveRecord?
Hooks triggered at certain moments in object lifecycle (before_save, after_create, etc.)
8. What is the difference between render and redirect_to?
- render: returns a view
- redirect_to: sends an HTTP redirect to another action or URL
9. What are scopes in Rails?
Reusable query logic defined in the model using scope :name, -> { ... }
10. How does Rails handle validations?
Via built-in validates methods in models (presence, uniqueness, length, etc.)
11. What is a concern in Rails?
A way to modularize and reuse code in models or controllers.
module Trackable
extend ActiveSupport::Concern
end
12. What is polymorphic association?
Allows a model to belong to more than one other model using a single association.
13. What is ActiveStorage?
Rails system for handling file uploads. Supports multiple backends (local, S3, etc.)
14. What are background jobs in Rails?
Used for async tasks. Implemented with ActiveJob and a backend (Sidekiq, DelayedJob, etc.)
15. Whatβs the difference between development, test, and production environments?
Each has its own config and database for safe separation of concerns and behavior.
16. What is eager loading in Rails?
Loading associated records in advance to avoid N+1 queries.
Post.includes(:comments)
17. What is rake and how is it used?
Rake is Rubyβs task runner. Rails adds tasks for db, testing, etc.
18. How do you secure a Rails app?
- Use strong params
- CSRF protection
- SQL injection prevention
- Secure headers
- Devise for authentication
19. How do you deploy a Rails app?
Common methods include:
- Capistrano
- Heroku
- Docker + Nginx + Puma
- Passenger + Apache/Nginx
20. What are partials in Rails views?
Reusable view snippets prefixed with _ and rendered using render 'partial_name'.
π Want the Full Rails Interview Bible?
β
Includes:
- 80+ technical questions
- Real-world Rails architecture
- Hot topics: Turbo, Hotwire, ActiveStorage, Sidekiq, deployment tips