app/controllers/spree/api/variants_controller.rb in solidus_api-2.2.2 vs app/controllers/spree/api/variants_controller.rb in solidus_api-2.3.0.beta1
- old
+ new
@@ -63,11 +63,12 @@
if current_ability.can?(:manage, Variant) && params[:show_deleted]
variants = variants.with_deleted
end
+ in_stock_only = ActiveRecord::Type::Boolean.new.cast(params[:in_stock_only])
variants = variants.accessible_by(current_ability, :read)
- variants = variants.in_stock if params[:in_stock_only] || cannot?(:view_out_of_stock, Spree::Variant)
+ variants = variants.in_stock if in_stock_only || cannot?(:view_out_of_stock, Spree::Variant)
variants
end
def variant_params
params.require(:variant).permit(permitted_variant_attributes)