mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-10 16:05:22 +02:00
AI chat layout skeleton
This commit is contained in:
parent
dd75cadebc
commit
d1b83541c1
23 changed files with 231 additions and 1 deletions
17
app/controllers/chats_controller.rb
Normal file
17
app/controllers/chats_controller.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
class ChatsController < ApplicationController
|
||||
def index
|
||||
Current.user.update!(current_chat: nil)
|
||||
@chats = Current.user.chats.ordered
|
||||
end
|
||||
|
||||
def create
|
||||
@chat = Current.user.chats.create_with_defaults!
|
||||
|
||||
redirect_to chat_path(@chat)
|
||||
end
|
||||
|
||||
def show
|
||||
@chat = Current.user.chats.find(params[:id])
|
||||
Current.user.update!(current_chat: @chat)
|
||||
end
|
||||
end
|
18
app/controllers/messages_controller.rb
Normal file
18
app/controllers/messages_controller.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
class MessagesController < ApplicationController
|
||||
before_action :set_chat
|
||||
|
||||
def create
|
||||
@message = @chat.messages.create!(message_params.merge(role: "user"))
|
||||
|
||||
redirect_to chat_path(@chat)
|
||||
end
|
||||
|
||||
private
|
||||
def set_chat
|
||||
@chat = Current.user.chats.find(params[:chat_id])
|
||||
end
|
||||
|
||||
def message_params
|
||||
params.require(:message).permit(:content)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue