mardi 5 mai 2015

Rails Active Record .where statement optimization

I'm building an ecommerce site and want to use an active record where statement to find shipments that are scoped to a certain supplier and certain shipment states. Here's what I have now:

Spree::Shipment.where("stock_location_id = ? and "state = ?", spree_current_user.supplier.stock_locations.first.stock_location_id, 'shipped' || 'ready')

I've found that this results in only 'shipped' statements get returned. I'd like it to display both shipped, and ready shipments. So far I can only get it to show one or the other, depending on if i put 'shipped' or 'ready' first in the query.

I'm guessing I have put the OR operator (||) in the wrong place, even though there are no errors. Can someone tell me a proper way to place OR operators in a condition in the where statement?

Thanks,

  • Brandon

Aucun commentaire:

Enregistrer un commentaire