rails 3 - SQL pass variable to "order"
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?
You could do:
[code].order("SUM((prices.price * #{params[:prod_id].to_i}) + profiles.shippingCost)").all
精彩评论