app/controllers/flyboy/task_comments_controller.rb in flyboy-0.0.2 vs app/controllers/flyboy/task_comments_controller.rb in flyboy-0.0.3
- old
+ new
@@ -1,15 +1,13 @@
#encoding: utf-8
module Flyboy
class TaskCommentsController < ::Flyboy::ApplicationController
- before_action :set_objects
-
def create
- @task = Task.find(params[:task_id])
+ @task ||= Task.find(params[:task_id])
+ @comment ||= @task.comments.new(task_comment_params)
- @comment = @task.comments.new(task_comment_params)
@comment.date = DateTime.now # TODO : Export to model ?
authorize! :update, @task
if @comment.save
@@ -18,13 +16,9 @@
render "flyboy/tasks/show"
end
end
private
-
- def set_objects
- @task = Task.find params[:task_id]
- end
def permitted_params
[:progress, :description]
end