testmycode/tmc-server

View on GitHub
app/controllers/feedback_replies_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

# Handles replying to a feedback answer by e-mail.
class FeedbackRepliesController < ApplicationController
  def create
    answer = FeedbackAnswer.find(params['answer_id'])
    authorize! :reply_feedback_answer, answer
    answer.reply_to_feedback_answers.create(from: current_user.email, body: params['body'])

    FeedbackReplyMailer.feedback_email(
      current_user.email,
      params['email'],
      params['body'],
      answer.exercise_name
    ).deliver_now

    if request.referer.present?
      redirect_to request.referer, params: { notice: 'Reply to a review was mailed' }
    else
      redirect_back fallback_location: root_path
    end
  end
end