Created
May 27, 2014 14:51
-
-
Save kruszczynski/f771f73fa2b4df80223e to your computer and use it in GitHub Desktop.
Sunspot #with method bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Project.search do | |
case params[:type] | |
when 'healthy' | |
with(:health_score, 80..100) | |
# => [80, 81, ... , 99, 100] | |
when 'at_risk' | |
with(:health_score, 50...80) | |
# => [50, 51, ... , 79, 80] - should not inlcude 80, inner Sunspot Range evaluation error | |
end | |
# possible fix: | |
case params[:type] | |
when 'healthy' | |
with(:health_score, (80..100).to_a) | |
# => [80, 81, ... , 99, 100] | |
when 'at_risk' | |
with(:health_score, (50...80).to_a) | |
# => [50, 51, ... , 79] - all good when preventing sunspot from evaluating Range object | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment