mirror of
https://github.com/kingomarnajjar/curly-happiness.git
synced 2026-07-26 06:37:18 +10:00
21 lines
560 B
Ruby
21 lines
560 B
Ruby
class ConversationsController < ApplicationController
|
|
before_action :authenticate_user!
|
|
def index
|
|
@users = User.all
|
|
@conversations = Conversation.all
|
|
end
|
|
def create
|
|
if Conversation.between(params[:sender_id],params[:recipient_id])
|
|
.present?
|
|
@conversation = Conversation.between(params[:sender_id],
|
|
params[:recipient_id]).first
|
|
else
|
|
@conversation = Conversation.create!(conversation_params)
|
|
end
|
|
redirect_to conversation_messages_path(@conversation)
|
|
end
|
|
private
|
|
def conversation_params
|
|
params.permit(:sender_id, :recipient_id)
|
|
end
|
|
end
|