Sha256: 9683482d006321de4f493aacef83d1190bd6fb745afdcd7112f9ddc1ec870e64

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module Peoplefinder
  class InformationRequestsController < ApplicationController
    before_action :set_recipient

    def new
      @information_request = InformationRequest.new(
        recipient: @person,
        message: I18n.t(
          'peoplefinder.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

2 entries across 2 versions & 1 rubygems

Version Path
peoplefinder-0.1.1 app/controllers/peoplefinder/information_requests_controller.rb
peoplefinder-0.1.0 app/controllers/peoplefinder/information_requests_controller.rb