infusionvlc/ConexionFelina

View on GitHub
app/controllers/assignments_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
class AssignmentsController < ApplicationController
  def index
    @colony_id = params[:colony_id]
    @assignments = Assignment.where(colony_id: @colony_id)
  end

  def new
    @assignment = Assignment.new(colony_id: params[:colony_id])
  end

  def create
    @assignment = Assignment.new(assignment_params)
    @assignment.save
    redirect_to(colony_path(@assignment.colony_id))
  end

  def show
    @assignment = Assignment.find(params[:id])
  end

  def destroy
    @assignment = Assignment.find(params[:id])
    @assignment.destroy
    redirect_to(colony_path(@assignment.colony_id))
  end

  private

  def assignment_params
    params.require(:assignment).permit(:colony_id, :task_id)
  end
end