Sha256: 3f2f94bd9ba5ec63af0af1bfc1a35f138c20ee86b95d05498390167b6e57423f

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

#encoding: utf-8

module Flyboy
  class TaskCommentsController < ::Flyboy::ApplicationController
    before_action :set_objects

    def create
      @task = Task.find(params[:task_id])

      @comment = @task.comments.new(task_comment_params)
      @comment.date = DateTime.now # TODO : Export to model ?

      authorize! :update, @task

      if @comment.save
        redirect_to @task
      else
        render "flyboy/tasks/show"
      end
    end

    private

    def set_objects
      @task = Task.find params[:task_id]
    end

    def permitted_params
      [:progress, :description]
    end

    def task_comment_params
      params.require(:task_comment).permit(permitted_params)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flyboy-0.0.2 app/controllers/flyboy/task_comments_controller.rb