Sha256: 0654a93dc7c7c828fc67b671f3ed9d53c990e73e7415e7c91128c350961b742f

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module Peoplefinder
  class InformationRequestsController < ApplicationController
    before_action :set_recipient

    def new
      @information_request = InformationRequest.new(
        recipient: @person,
        message: I18n.t('controllers.information_requests.default_message',
          recipient: @person,
          sender: current_user)
        )
    end

    def create
      @information_request = InformationRequest.new(information_request_params)
      @information_request.recipient = @person
      @information_request.sender_email = current_user.email

      if @information_request.save
        ReminderMailer.information_request(@information_request).deliver
        notice :message_sent, person: @person
        redirect_to person_path(@person)
      else
        render action: :new
      end
    end

  private

    def set_recipient
      @person = Person.friendly.find(params[:person_id])
    end

    def information_request_params
      params.require(:information_request).permit(
        :message
        )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
peoplefinder-0.0.2 app/controllers/peoplefinder/information_requests_controller.rb