I am using the following code to check if a variable is not nil and not zero
if(discount != nil && discount != 0) ... end
Is the
When dealing with a database record, I like to initialize all empty values with 0, using the migration helper:
add_column :products, :price, :integer, default: 0