An Input Controller is a design pattern described by Martin Fowler in his book “Patterns of Enterprise Application Architecture.” It is responsible for handling user input and directing it to the appropriate application logic. The Input Controller pattern centralizes the control logic for processing user inputs, making it easier to manage and maintain. The Input Controller is the C in the Model-View-Controller pattern.

Key Characteristics:

Key Responsibilities:

In a Ruby on Rails application, the ArticlesController can be considered an example of an Input Controller. It handles HTTP requests, validates input, invokes business logic, and renders responses.

class ArticlesController < ApplicationController
  def index
    @articles = Article.all
  end

  def show
    @article = Article.find(params[:id])
  end

  def new
    @article = Article.new
  end

  def create
    @article = Article.new(article_params)
    if @article.save
      redirect_to @article
    else
      render 'new'
    end
  end

  private

  def article_params
    params.require(:article).permit(:title, :text)
  end
end

The Input Controller pattern can be broken down into two separate patterns: Page Controller and the Front Controller