Class: Observ::ChatsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/observ/chats_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/observ/chats_controller.rb', line 15

def create
  @chat = ::Chat.new(params_chat)

  # Set prompt name from agent if applicable
  set_prompt_info_from_agent

  if @chat.save
    redirect_to chat_path(@chat), notice: "Chat was successfully created."
  else
    render :new, status: :unprocessable_content
  end
end

#indexObject



5
6
7
8
9
# File 'app/controllers/observ/chats_controller.rb', line 5

def index
  @chats = ::Chat.order(created_at: :desc)
    .page(params[:page])
    .per(Observ.config.pagination_per_page)
end

#newObject



11
12
13
# File 'app/controllers/observ/chats_controller.rb', line 11

def new
  @chat = ::Chat.new
end

#showObject



28
29
30
# File 'app/controllers/observ/chats_controller.rb', line 28

def show
  @message = @chat.messages.build
end