Class: Layered::Assistant::Public::ConversationsController

Inherits:
ApplicationController show all
Includes:
StoppableResponse
Defined in:
app/controllers/layered/assistant/public/conversations_controller.rb

Instance Method Summary collapse

Methods included from StoppableResponse

#stop

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/layered/assistant/public/conversations_controller.rb', line 10

def create
  @conversation = @assistant.conversations.new(name: Conversation.default_name)

  if @conversation.save
    add_conversation_to_session(@conversation)
    redirect_to layered_assistant.public_conversation_path(@conversation)
  else
    redirect_to layered_assistant.public_assistant_path(@assistant)
  end
end

#showObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/layered/assistant/public/conversations_controller.rb', line 21

def show
  @page_title = @conversation.name
  @messages = @conversation.messages.includes(:model).by_created_at
  @conversations = if session_conversation_uids.any?
    Conversation.joins(:assistant).merge(Assistant.publicly_available)
      .where(uid: session_conversation_uids, assistant: @conversation.assistant)
      .by_created_at
      .limit(20)
  else
    Conversation.none
  end
end