You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rails ActiveRecord has a method called exists? which returns a boolean true if the record exists or false if not.
This method now always returns ```false` ' if I give it a hashid instead of a normal ID.
Example code:
context.cart[:items]=context.cart[:items].selectdo |cart_item_hashid|
Shop::Item.exists?(cart_item_hashid)# always false, Cart is emptiedend
It should generate the following SQL:
SELECT1AS one FROM`shop_items`WHERE`shop_items`.`id`=14LIMIT1
Rails ActiveRecord has a method called exists? which returns a boolean
true
if the record exists orfalse
if not.This method now always returns ```false` ' if I give it a hashid instead of a normal ID.
Example code:
It should generate the following SQL:
The current solution I'm using:
This generates the following SQL:
This returns the whole record from the DB to check in Ruby code that it is not ```nil` '; it would be much more efficient just to return a boolean.
Another workaround is to do the following:
It works fine; however, it is a bit redundant.
The text was updated successfully, but these errors were encountered: