Hello so I have an app that works great locally but as soon as I pushed it to Heroku I'm having issues.
HEROKU LINK: https://sleepy-garden-73993.herokuapp.com
GITHUB REPO: https://github.com/kbachand/ginger_ails
ERROR IN CONSOLE WHEN INSPECT THE PAGE: Failed to load resource: the server responded with a status of 500 (Internal Server Error)
HOW TO DUPLICATE ISSUE:
-Click "check your address", ENTER address: 202 tryon st; ZIP code: 28207 (this is in our service area)
-Click "select your ailment" and select one (any will work)
-Click "purchase remedy kit", and it will prompt you to login or sign up. You can sign up if you'd like but my login is keithbtest@gmail.com and password: surfsup714
-Once you login click "purchase remedy kit" and it SHOULD render a view that shows you all the items in the cart and allows you to empty or purchase via stripe. But instead you get the error.
HEROKU LOG:
2016-11-02T18:15:02.693028+00:00 app[web.1]: [1m[36mCart Load (1.4ms)[0m [1mSELECT "carts".* FROM "carts" WHERE "carts"."id" = $1 LIMIT 1[0m [["id", 1]]
2016-11-02T18:15:02.696486+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::DatatypeMismatch: ERROR: argument of WHERE must be type boolean, not type integer
2016-11-02T18:15:02.695276+00:00 app[web.1]: [1m[35mUser Load (1.8ms)[0m SELECT "users".* FROM "users" WHERE (1) LIMIT 1
2016-11-02T18:15:02.695572+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms (ActiveRecord: 4.6ms)
2016-11-02T18:15:02.696484+00:00 app[web.1]:
2016-11-02T18:15:02.696487+00:00 app[web.1]: ^
2016-11-02T18:15:02.696486+00:00 app[web.1]: LINE 1: SELECT "users".* FROM "users" WHERE (1) LIMIT 1
2016-11-02T18:15:02.696488+00:00 app[web.1]: : SELECT "users".* FROM "users" WHERE (1) LIMIT 1):
2016-11-02T18:15:02.696488+00:00 app[web.1]: app/controllers/carts_controller.rb:35:in `show'
2016-11-02T18:15:02.696489+00:00 app[web.1]:
2016-11-02T18:15:02.696489+00:00 app[web.1]:
2016-11-02T18:18:42.858131+00:00 heroku[router]: at=info method=GET path="/" host=sleepy-garden-73993.herokuapp.com request_id=5c66a6cc-7de8-43b6-92c3-51b63a3d3ab7 fwd="104.139.26.81" dyno=web.1 connect=1ms service=18ms status=200 bytes=6966
The important bits on the log are:
"ActiveRecord::StatementInvalid (PG::DatatypeMismatch: ERROR: argument of WHERE must be type boolean, not type integer "
Below it reads the error is on app/controllers/carts_controller.rb:35
https://github.com/kbachand/ginger_ails/blob/master/app/controllers/carts_controller.rb#L35
On that line you have:
@user = User.find_by(id: params[:id])
So it looks like params[:id]
is an integer, but the id
column is a boolean.
When looking at your schema.rb to check your column types, I realized you have the devise
gem installed, so you should use devise's helpers to authenticate the user instead of doing it manually:
https://github.com/plataformatec/devise#controller-filters-and-helpers
Let me know if that helps!