Skip to content

Instantly share code, notes, and snippets.

@slbug
Created September 17, 2012 17:57
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 slbug/3738781 to your computer and use it in GitHub Desktop.
Save slbug/3738781 to your computer and use it in GitHub Desktop.
# Code before:
resources :messages do
resources :comments
end
resources :posts do
resources :comments
resources :images, only: :index
end
# Code after:
concern :commentable do
resources :comments
end
concern :image_attachable do
resources :images, only: :index
end
resources :messages, concerns: :commentable
resources :posts, concerns: [:commentable, :image_attachable]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment