Skip to content

Instantly share code, notes, and snippets.

@googya
Last active December 14, 2015 19:09
Show Gist options
  • Select an option

  • Save googya/5134404 to your computer and use it in GitHub Desktop.

Select an option

Save googya/5134404 to your computer and use it in GitHub Desktop.
重写hash的键
para_options = params.slice(:search_index, :operation, :keywords)
# options = para_options.inject({}){|h, (k,v)| h[k.camelize] = v; h }
options = para_options.each_with_object({}){|(k,v), h| h[k.camelize] = v }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment