Created
June 27, 2012 07:48
-
-
Save bradherman/3002282 to your computer and use it in GitHub Desktop.
This file contains 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
# typical route | |
get '/my_model' do | |
# return query results if search param, otherwise return all | |
if params[:relation_id] | |
MyModel.all(:relation_id => params[:relation_id], :order => :name.asc) | |
else | |
MyModel.all(:order => :name.asc) | |
end | |
end | |
# proposed change | |
get '/my_model' do | |
# a nil param returns all instead of all models with param set to nil | |
MyModel.all(:relation_id.nilcon => params[:relation_id], :order => :name.asc) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment