Skip to content

Instantly share code, notes, and snippets.

@alekseyl
Last active December 13, 2016 09:05
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 alekseyl/d0e7c70c968c4436ba81abb67c59d3a3 to your computer and use it in GitHub Desktop.
Save alekseyl/d0e7c70c968c4436ba81abb67c59d3a3 to your computer and use it in GitHub Desktop.
for medium article 'Rails fast collection render'
# nil means current_user is empty i.e. it's a guest
keys = [ [:user, :admin, :moderator, nil], [:ru, :en ] ]
# all combination of keys:
all_flatten_keys = keys.pop.product(*keys)
# [[:ru, :user], [:ru, :admin], [:ru, :moderator], [:ru, nil],
# [:en, :user], [:en, :admin], [:en, :moderator], [:en, nil]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment