Rails testing error: argument of WHERE must be type boolean, not type integer -


users can vote posts through has_many association. i'm getting error running tests:

activerecord::statementinvalid: pg::datatypemismatch: error: argument of must type boolean, not type integer 

from test:

test "should unvote post standard way"   @user.vote(@post_2)   postvoterelationship = @user.active_post_vote_relationships.find_by(voted_id: @post_2.id)   assert_difference '@user.postvoting.count', -1     delete postvoterelationship_path(postvoterelationship)   end end 

postvoterelationships_controller.rb

def destroy   @user = postvoterelationship.find(params[:id]).voter   @post = postvoterelationship.find_by(params[:id]).voted   @user.unvote(@post)   respond_to |format|     format.html       redirect_to @user     end     format.js   end end # destroy 

routes.rb

resources :postvoterelationships,  only: [:create, :destroy] 

postvoterelationship.rb

class postvoterelationship < activerecord::base   belongs_to :voter, class_name: "user"   belongs_to :voted, class_name: "post"   validates  :voter_id, presence: true   validates  :voted_id, presence: true end 

user.rb

has_many :postvoting, through: :active_post_vote_relationships, source: :voted 

edit:

server logs:

started delete "/postvoterelationships/207" ::1 @ 2015-06-16 21:02:07 +0100 processing postvoterelationshipscontroller#destroy js parameters: {"utf8"=>"✓", "authenticity_token"=>"bp17swn2k6lfqnnxea6nneo5ywxkgopi9psxliekzoor3xuff4chhs3+w+9wp8eb3gwzfhsauaypiip1/kkh9a==", "commit"=>"unvote", "id"=>"207"} character load (0.3ms)  select  "characters".* "characters" "characters"."callsign" = $1 limit 1  [["callsign", "bazzer"]] user load (0.4ms)  select  "users".* "users" "users"."id" = $1 limit 1  [["id", 1]] postvoterelationship load (1.2ms)  select  "postvoterelationships".* "postvoterelationships" "postvoterelationships"."id" = $1 limit 1  [["id", 207]] character load (0.7ms)  select  "characters".* "characters" "characters"."id" = $1 limit 1  [["id", 1]] postvoterelationship load (1.8ms)  select  "postvoterelationships".* "postvoterelationships" (207) limit 1 pg::datatypemismatch: error:  argument of must type boolean, not type integer line 1: ...ationships".* "postvoterelationships" (207) limit...                                                          ^ : select  "postvoterelationships".* "postvoterelationships" (207) limit 1 completed 500 internal server error in 14ms (activerecord: 4.3ms)  activerecord::statementinvalid (pg::datatypemismatch: error:  argument of must type boolean, not type integer line 1: ...ationships".* "postvoterelationships" (207) limit...                                                          ^ : select  "postvoterelationships".* "postvoterelationships" (207) limit 1): app/controllers/postvoterelationships_controller.rb:24:in `destroy' 

this not complete answer, can't post comments (not enough reputation).

have tried @ sql queries made? can show them in test environment, check this question.

and, in postvoterelationships_controller.rb, think:

  @post = postvoterelationship.find_by(params[:id]).voted 

should be:

  @post = postvoterelationship.find(params[:id]).voted 

Comments

  1. Most of the time I don’t make comments on websites, but I'd like to say that this article really forced me to do so. Really nice post!
    pg auto

    ReplyDelete
  2. I must say, I thought this was a pretty interesting read when it comes to thisC topic. Liked the material. . .
    https://www.ufa365.info/

    ReplyDelete
  3. My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more!
    เดิมพันกีฬาออนไลน์

    ReplyDelete
  4. Consequently, starting in the amount of electronic marketing strategy, is whenever a company's existing website, which will be to review the present site and its purpose is to improve the potency of the future. There is no evidence that the development an
    แทงบอลสเต็ป

    ReplyDelete
  5. Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing...
    ufa365

    ReplyDelete
  6. I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work.
    ufa365

    ReplyDelete
  7. I must say, I thought this was a pretty interesting read when it comes to thisC topic. Liked the material. . .
    บอลออนไลน์ฟรี

    ReplyDelete
  8. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained!
    เว็บพนันฝากถอนอัตโนมัติ

    ReplyDelete
  9. We run a community that promotes massage and leaves reviews, so why don't you come in and take a look?
    รีวิวเว็บพนัน

    ReplyDelete
  10. Most of the time I don’t make comments on websites, but I'd like to say that this article really forced me to do so. Really nice post!
    บาคาร่ายอดฮิต

    ReplyDelete
  11. Consequently, starting in the amount of electronic marketing strategy, is whenever a company's existing website, which will be to review the present site and its purpose is to improve the potency of the future. There is no evidence that the development an
    รีวิวเว็บพนันออนไลน์ufa365

    ReplyDelete
  12. My friend mentioned to me your blog, so I thought I’d read it for myself. Very interesting insights, will be back for more!
    แทงบาสเว็บไหนดี

    ReplyDelete
  13. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for.
    เอาชนะสล็อต

    ReplyDelete
  14. You have raised an important issue..Thanks for sharing..I would like to read more current affairs from this blog..keep posting..
    เกมส์สล็อต

    ReplyDelete
  15. I am always searching online for articles that can help me. There is obviously a lot to know about this. I think you made some good points in Features also. Keep working, great job!
    lucky-god

    ReplyDelete
  16. It turns out that even the hottest port has a few places where you can get off the beaten path. Here are some recommendations that will make you feel like you're in the know
    เทคนิคการเล่นรูเล็ต

    ReplyDelete
  17. Most of the time I don’t make comments on websites, but I'd like to say that this article really forced me to do so. Really nice post! ประวัตินักฟุตบอลไทย

    ReplyDelete

Post a Comment

Popular posts from this blog

swift - How to change text of a button with a segmented controller? -

python - How to create jsonb index using GIN on SQLAlchemy? -

PHP DOM loadHTML() method unusual warning -