24 lines
620 B
Ruby
24 lines
620 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ConversationsController < ApplicationController
|
|
def index
|
|
@conversations = @current_user.conversations
|
|
end
|
|
|
|
def show
|
|
@conversation = @current_user.conversations.find(params[:id])
|
|
@messages = @conversation.messages
|
|
@prompt = Message.new(conversation: @conversation)
|
|
end
|
|
|
|
def create
|
|
# NOTE: Real application would have agent be given from params
|
|
@conversation = @current_user.conversations.new(agent: 'DummyAgent')
|
|
if @conversation.save
|
|
redirect_to @conversation
|
|
else
|
|
render :index, status: :unprocessable_entity
|
|
end
|
|
end
|
|
end
|