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
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!
ReplyDeletepg auto
I must say, I thought this was a pretty interesting read when it comes to thisC topic. Liked the material. . .
ReplyDeletehttps://www.ufa365.info/
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เดิมพันกีฬาออนไลน์
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แทงบอลสเต็ป
Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing...
ReplyDeleteufa365
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.
ReplyDeleteufa365
I must say, I thought this was a pretty interesting read when it comes to thisC topic. Liked the material. . .
ReplyDeleteบอลออนไลน์ฟรี
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เว็บพนันฝากถอนอัตโนมัติ
We run a community that promotes massage and leaves reviews, so why don't you come in and take a look?
ReplyDeleteรีวิวเว็บพนัน
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บาคาร่ายอดฮิต
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รีวิวเว็บพนันออนไลน์ufa365
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แทงบาสเว็บไหนดี
Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for.
ReplyDeleteเอาชนะสล็อต
You have raised an important issue..Thanks for sharing..I would like to read more current affairs from this blog..keep posting..
ReplyDeleteเกมส์สล็อต
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!
ReplyDeletelucky-god
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เทคนิคการเล่นรูเล็ต
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