I am making a chat room app. It's as simple as creating a room and exchanging messages with other users in it.
Clicking on a message posted in the room will take you to the comments page
Therefore, when I try to post a comment by typing characters in the comment field, an unknown action error occurs.
[Question] I thought that the new action and create action would work because I posted a comment and saved it in the table, but why is the update method working? I would be very grateful if you could tell me here. And how are comments saved?
Corresponding source code
Error message Unknown action The action'update' could not be found for RoomsController
[New.html.erb (comment)] <% if current_user%> <% = form_with (model: [@room], local: true) do | f |%> <% = f.text_area: text, placeholder: "comment", rows: "2"%> <% = f.submit "SEND"%> <% end%><% else%> <strong><p>* * * New registration/login is required to post comments * * *</p></strong><% end%>
[Comments.controller.rb] class CommentsController</pre><pre><code data-language = "Ruby">[_Main_chat.html.erb] <% = @ room.name%> <% if current_user.genre == "teacher"%> <% = link_to "Delete room", room_path (@room), method :: delete%><% end%> <% = message.user.name%> <% = l message.created_at%> <% = link_to message.content, new_room_message_comment_path (@room, @messages)%> <% = image_tag message.image.variant (resize: '400x400'), class:'message-image' if message.image.attached?%><% = form_with model: [@room, @message], class:'form', local: true do | f |%> <% = f.text_field: content, class:'form-message', placeholder:'type a message'%><label> <span>image</span> <% = f.file_field: image, class:'hidden'%></label><% = f.submit'submit', class:'form-submit'%><% end%>
[Routes.rb] Rails.application.routes.draw do devise_for: usersget'messages/index' get'comments/index' root to: "rooms # index" resources: users resources: rooms do resources: messages do resources: comments end end end
[Coment.rb] class Comment</pre> <pre><code data-language = "Ruby">[Rooms.controller.rb] class RoomsController</pre> <pre><code data-language = "Ruby"> room_message_comments GET/rooms /: room_id/messages /: message_id/comments (.: format) comments # index POST/rooms /: room_id/messages /: message_id/comments (.: format) comments # create new_room_message_comment GET/rooms /: room_id/messages /: message_id/comments/new (.: format) comments # new room_message_comment GET/rooms /: room_id/messages /: message_id/comments /: id (.: format) comments # show
Answer # 1
- ruby on rails - pg :: datatypemismatch error when doing heroku run rails db: migrate
- ruby on rails - i get an error in a program that changes over time
- ruby - an error occurs when building a rails 6 environment with docker
- ruby on rails - i want to download a file with rails, s3 and carrierwave, but i get an error
- ruby on rails - rspec test changed by -1, but was changed by 0 error
- ruby on rails - i get an error without being created
- ruby on rails 6 - [error] uninitialized constant user (call'userconnection' to establish a connection) :: image
- ruby on rails - i want to resolve rails name error
- ruby on rails - nomethoderror in itemscontroller # new error
- ruby - data is not updated by update action rails
- ruby on rails - rails routing error
- ruby on rails - syntax error cannot be resolved
- ruby - about error of update action when nesting
- ruby on rails - i want to put what i posted on the show page, but it's a blank page it's not an error
- ruby on rails - about rails create action
- ruby - [rails aws ec2] action cable works on port 3000 on aws, but an error occurs on port 80 (http)
- ruby on rails - error when implementing rails6 follow function
- ruby on rails - create a chat feature with action cable on ec2 on rails aws
- ruby on rails 5 - i want to get an error message when i enter the user id in full-width in url
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
form_with (model: [@room],That's why.
@room is an "existing" "instance of Room", isn't it?
Therefore, the update of RoomsController is called.