Reputation: 7166
Im trying to pass variable to the order...
[code].order(['SUM((prices.price * ?) + profiles.shippingCost)', params[:prod_id]]).all
But it doesn't convert the variable to sql instead it gives me.(the variable in this case was "1").
GROUP BY price ORDER BY SUM((prices.price * ?) + profiles.shippingCost), 1):
Is this even possible to do?
Upvotes: 1
Views: 934
Reputation: 64177
You could do:
[code].order("SUM((prices.price * #{params[:prod_id].to_i}) + profiles.shippingCost)").all
Upvotes: 1