Skip to content

Commit cbda5d5

Browse files
fix message detail (#215)
Co-authored-by: Vijay Swamidass <[email protected]>
1 parent c5b7a6b commit cbda5d5

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

app/controllers/base_messages_controller.rb

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ def create
3434
end
3535
end
3636

37-
# DELETE /messages/1 or /messages/1.json
38-
def destroy
39-
@message.destroy!
40-
41-
respond_to do |format|
42-
format.html { redirect_to messages_url, notice: 'Message was successfully destroyed.' }
43-
format.json { head :no_content }
44-
end
45-
end
46-
4737
private
4838

4939
# Use callbacks to share common setup or constraints between actions.
@@ -52,7 +42,11 @@ def set_message
5242
end
5343

5444
def set_chat
55-
@chat = Chat.find(params[:chat_id])
45+
if params[:chat_id].present?
46+
@chat = Chat.find(params[:chat_id])
47+
elsif @message&.chat
48+
@chat = @message.chat
49+
end
5650
end
5751

5852
# Only allow a list of trusted parameters through.

app/views/messages/show.html.erb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
<div class="mx-auto md:w-2/3 w-full flex">
22
<div class="mx-auto">
3+
<%= render partial: 'shared/breadcrumb', locals: { breadcrumbs: [['Home', root_path], [@chat.assistant.name, assistant_path(@chat.assistant)], ['Chat', @chat], ['Message', nil]] } %>
34

45
<%= render @message %>
5-
6-
<%= link_to "Edit this message", edit_message_path(@message), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
7-
<%= link_to "Back to messages", messages_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
8-
<div class="inline-block ml-2">
9-
<%= button_to "Destroy this message", @message, method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
10-
</div>
116
</div>
127
</div>

0 commit comments

Comments
 (0)