# RESTful controller for Project model.
class ProjectsController < ApplicationController
  before_filter :set_project, only: %i[show edit update destroy]

  def index
    @projects = Project.all.includes(:viewports)
  end

  def show
    render
  end

  def new
    @project = Project.new
  end

  def edit
    render
  end

  def create
    @project = Project.new(project_params)
    if @project.save
      redirect_to @project, notice: 'Project was successfully created.'
    else
      render action: 'new'
    end
  end

  def update
    if @project.update_attributes(project_params)
      redirect_to @project, notice: 'Project was successfully updated.'
    else
      render action: 'edit'
    end
  end

  def destroy
    @project.destroy
    redirect_to projects_url, notice: 'Project was successfully destroyed.'
  end

  private

  def set_project
    @project = Project.find(params[:id])
  end

  def project_params
    params.require(:project).permit(:name, :viewport_widths, :url_addresses)
  end
end

# RESTful controller for Project model.
class ProjectsController < ApplicationController
  before_filter :set_project, only: %i[show edit update destroy]

  def index
    @projects = Project.order(:name).includes(:viewports)
  end

  def show
    render
  end

  def new
    @project = Project.new
  end

  def edit
    render
  end

  def create
    @project = Project.new(project_params)
    if @project.save
      redirect_to @project, notice: 'Project was successfully created.'
    else
      render action: 'new'
    end
  end

  def update
    if @project.update_attributes(project_params)
      redirect_to @project, notice: 'Project was successfully updated.'
    else
      render action: 'edit'
    end
  end

  def destroy
    @project.destroy
    redirect_to projects_url, notice: 'Project was successfully destroyed.'
  end

  private

  def set_project
    @project = Project.find(params[:id])
  end

  def project_params
    params.require(:project).permit(:name, :viewport_widths, :url_addresses)
  end
end

Order projects list by name
Order projects list by name

To prevent these from moving around willy-nilly and to improve the
findability of data, I am alphabetizing the list of projects on the
ProjectsController#index page.

Change-Id: I2164558e236de843198c12a782a64f44cf20e78a
