Skip to content

Instantly share code, notes, and snippets.

@rimian
Created September 13, 2012 09:52
Show Gist options
  • Save rimian/3713300 to your computer and use it in GitHub Desktop.
Save rimian/3713300 to your computer and use it in GitHub Desktop.
# Doesn't work when code = nil because the operator in the SQL should be 'is' not '='
def shipping_options
if @promotion.present?
code = @promotion.code
else
code = nil
end
Shipping.where('promotion_code = ? AND is_bulky = ? AND minimum_spend <= ?',
code, self.bulky_order?, self.calculate_total_price.to_f)
end
@rimian
Copy link
Author

rimian commented Sep 13, 2012

something like this:
Shipping.where(:promotion_code => '').where(:price => 0.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment