0

I get this error whenever I try to destroy a record. I don't get why this isn't working.

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

My controller:

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

I've also tried doing it this way:

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

How I'm doing it in the view:

 <%= 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 %>

The schema:

  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
3
  • I've seen this error happen when arguments are passed out of expected position. Commented Aug 22, 2019 at 2:42
  • @JSpratt, I'm not sure what you mean. I updated my question with another thing I tried. Commented Aug 22, 2019 at 3:31
  • 1
    Can you post application logs @ddonche? Commented Aug 22, 2019 at 5:45

1 Answer 1

0

I think you are passing "Notation" as :id in your destroy path. Try double checking your comment_notation_path(@comment, notation) path

Sign up to request clarification or add additional context in comments.

2 Comments

I'm not sure what you mean here. I am destroying this like I destroy all the other things. In fact, I use the code exactly the way it's done in the Rails Tutorial by Michael Hartl. I was under the impression you find the record by its id and then destroy it. Is that not what's supposed to happen?
I think this will solve your problem stackoverflow.com/questions/20715190/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.