I am creating an SNS application like Twitter with rails.
I have already implemented the message posting function and the like function, but I am working on implementing the "delete function" and "editing function" of the posted content. The following error occurred when I implemented the delete function and sent a "delete" request for a message posted from the view.

The message controller is below.

def destroy
    message = Message.find (params [: id])
  def message_params
    params.require (: message) .permit (: content,: image) .merge (user_id: current_user.id)

The view looks like this:

        % span = image_tag'arrow_top.png'
        % ul.more_list
          % li
            = link_to'Delete', user_message_path (current_user.id, m.id), method:: delete

I would appreciate any advice.

  • Answer # 1

    I solved it by creating a file of "destroy.html.haml" in the messages directory and putting the following code.

        % h3
          The deletion is complete.
        % a.btn {: href =>"/"} Return to post list

Related articles