Technical Interview Questions for Ruby on Rails Developer
1. What is Ruby on Rails?
Answer: Ruby on Rails is a web application framework based on Ruby that follows the MVC architecture.
2. What are the main components of Rails MVC architecture?
Answer: MVC consists of Model for data, View for UI, and Controller for handling requests and responses.
3. What is Active Record in Rails?
Answer: Active Record is Rails’ ORM that allows developers to interact with databases using Ruby objects.
4. What is the difference between Rails and Ruby?
Answer: Ruby is a programming language, while Rails is a web development framework built using Ruby.
5. What are migrations in Rails?
Answer: Migrations are used to create, modify, and manage database schema changes.
6. What is a Rails controller?
Answer: A controller handles user requests, processes data, and returns responses.
7. What are Rails routes?
Answer: Routes define how application URLs map to controller actions.
8. What is the purpose of Gemfile in Rails?
Answer: Gemfile manages the dependencies and libraries required by a Rails application.
9. What is Bundler in Ruby on Rails?
Answer: Bundler manages Ruby gem dependencies and ensures compatible versions are installed.
10. What is the difference between has_many and belongs_to associations?
Answer: has_many defines a one-to-many relationship, while belongs_to connects a child record to a parent record.
11. What are validations in Rails?
Answer: Validations ensure that model data meets specific rules before saving to the database.
12. What are callbacks in Rails?
Answer: Callbacks allow developers to execute code automatically during an object's lifecycle.
13. What is Active Job in Rails?
Answer: Active Job is a framework for handling background tasks asynchronously.
14. What is the difference between render and redirect_to?
Answer: render displays a template, while redirect_to sends a new request to another action.
15. What is REST in Rails?
Answer: REST is an architectural style that organizes applications around resources and HTTP actions.
16. What is the purpose of RSpec?
Answer: RSpec is a testing framework used for writing and running Ruby application tests.
17. What is the difference between puts and print in Ruby?
Answer: puts adds a new line after output, while print does not.
18. What are Ruby blocks?
Answer: Blocks are pieces of code passed to methods for execution.
19. What is the difference between symbol and string in Ruby?
Answer: Symbols are immutable and memory-efficient, while strings are mutable objects.
20. How do you improve Rails application performance?
Answer: Performance can be improved using caching, database optimization, query improvements, and background jobs.