0

每当我尝试销毁记录时,我都会收到此错误。我不明白为什么这不起作用。

PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "Notation"

我的控制器:

  def destroy
    Notation.find(params[:id]).destroy
    respond_to do |format|
      format.html { redirect_to @commentable, notice: 'Reply was eradicated.' }
    end
  end

我也试过这样做:

  def destroy
    @notation = Notation.find(params[:id])
    @notation.destroy
    respond_to do |format|
      format.html { redirect_to @commentable, notice: 'Reply was eradicated.' }
    end
  end

我在视图中是如何做到的:

 <%= link_to comment_notation_path(@comment, notation), method: :delete, data: { confirm: "Are you sure?" } do %>
            <i class="fa fa-trash small ml-3" title="delete"></i><% end %>

架构:

  create_table "notations", force: :cascade do |t|
    t.integer "comment_id"
    t.integer "user_id"
    t.text "content"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
  end
4

1 回答 1

0

我认为您正在传递“符号”,就像:id您的destroy路径一样。尝试仔细检查您的comment_notation_path(@comment, notation)路径

于 2019-08-22T03:40:19.473 回答