Home>

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])
    message.destroy
  end
  private
  def message_params
    params.require (: message) .permit (: content,: image) .merge (user_id: current_user.id)
  end

The view looks like this:

    .more
        % 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.

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

Related articles