Skip to content

Instantly share code, notes, and snippets.

@canweriotnow
Created February 7, 2012 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canweriotnow/1761355 to your computer and use it in GitHub Desktop.
Save canweriotnow/1761355 to your computer and use it in GitHub Desktop.
Evil params checking
# In the controller:
private
def maybe(param)
if params[param]
{param => params[param]}
end
end
# Then in my controller action, I can do this:
@trans = AccountTransaction.where({:cust_id => params[:customer_id]}, maybe(:profitcenter), maybe(:merchant))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment