Skip to content

Instantly share code, notes, and snippets.

@bjoerne2
Created July 14, 2017 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerne2/af89616806d522c9d08cc8a76bf43c3d to your computer and use it in GitHub Desktop.
Save bjoerne2/af89616806d522c9d08cc8a76bf43c3d to your computer and use it in GitHub Desktop.
def create
@conversation_transient_model = ConversationTransientModel.new(conversation_params)
if @conversation_transient_model.valid?
recipients = User.where(id: @conversation_transient_model.recipients)
conversation = current_user.send_message(recipients, @conversation_transient_model.body, @conversation_transient_model.subject).conversation
flash[:notice] = "Your message was successfully sent!"
redirect_to conversation_path(conversation)
else
flash[:error] = "Errors found!"
render action: 'new'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment