Sha256: 56c4cda30cc92d9b380f1174ff705dff42e5fc37322dfd16880ffe2c4f1a2d5d

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true
class ProjectsController < ApplicationController
  include Authentication
  load_and_authorize_resource except: [:index]

  before_action :set_project, only: [:show, :edit, :update, :destroy]

  # GET /projects
  def index
    @projects = Project.all
  end

  # GET /projects/1
  def show
  end

  # GET /projects/new
  def new
    @project = Project.new
  end

  # GET /projects/1/edit
  def edit
  end

  # POST /projects
  def create
    @project = Project.new(project_params)

    if @project.save
      redirect_to @project, notice: 'Project was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /projects/1
  def update
    if @project.update(project_params)
      redirect_to @project, notice: 'Project was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /projects/1
  def destroy
    @project.destroy
    redirect_to projects_url, notice: 'Project was successfully destroyed.'
  end

  private

  # Use callbacks to share common setup or constraints between actions.
  def set_project
    @project = Project.find(params[:id])
  end

  # Only allow a trusted parameter "white list" through.
  def project_params
    params.require(:project).permit(:owner_id, :name, :closed)
  end
end

Version data entries

8 entries across 7 versions & 1 rubygems

Version Path
model_base_generators-0.4.0 examples/rails-5.1/app/controllers/projects_controller.rb
model_base_generators-0.4.0 examples/rails-5.0/app/controllers/projects_controller.rb
model_base_generators-0.3.9 example/app/controllers/projects_controller.rb
model_base_generators-0.3.8 example/app/controllers/projects_controller.rb
model_base_generators-0.3.7 example/app/controllers/projects_controller.rb
model_base_generators-0.3.6 example/app/controllers/projects_controller.rb
model_base_generators-0.3.5 example/app/controllers/projects_controller.rb
model_base_generators-0.3.4 example/app/controllers/projects_controller.rb