Skip to content

Instantly share code, notes, and snippets.

@domagude
Last active November 16, 2017 10:11
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 domagude/45f1768498363efc6d1292cb6972f77c to your computer and use it in GitHub Desktop.
Save domagude/45f1768498363efc6d1292cb6972f77c to your computer and use it in GitHub Desktop.
...
def create
recipient_id = Post.find(params[:post_id]).user.id
conversation = Private::Conversation.new(sender_id: current_user.id,
recipient_id: recipient_id)
if conversation.save
Private::Message.create(user_id: recipient_id,
conversation_id: conversation.id,
body: params[:message_body])
respond_to do |format|
format.js {render partial: 'posts/show/contact_user/message_form/success'}
end
else
respond_to do |format|
format.js {render partial: 'posts/show/contact_user/message_form/fail'}
end
end
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment