Created
August 10, 2016 14:40
-
-
Save randsina/19ccd4e08a3a5829fe5264874657c53d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AdminMessagesController < ApplicationController | |
before_action :authenticate_user!, only: [:create] | |
def create | |
@admin_message = current_user.admin_messages.new(message_params) | |
respond_to do |format| | |
if @admin_message.save | |
AdminMailer.new_message(email_params).deliver_later | |
@admin_message = AdminMessage.new | |
end | |
format.js { render :create } | |
end | |
end | |
private | |
def message_params | |
params.require(:admin_message).permit( | |
:sender_name, | |
:sender_phone, | |
:body | |
) | |
end | |
def email_params | |
message_params.merge({ recipient_email: Settings.instance.info_email, user_email: current_user.email }) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment