💎 Ruby on Rails
Beginner
What is the MVC pattern in Rails?
Answer
Rails uses the Model-View-Controller (MVC) pattern to separate concerns. The Model (ActiveRecord) handles data, business logic, and database interactions. The View (ActionView) handles presentation — ERB templates that render HTML. The Controller (ActionController) handles incoming HTTP requests, interacts with the model, and renders the appropriate view. A typical request flow: browser sends HTTP request → Router dispatches to a Controller action → Controller queries Model → Controller passes data to View → View renders HTML response.