Skip to content

Instantly share code, notes, and snippets.

@theHamdiz
Created April 23, 2016 22:18
Show Gist options
  • Select an option

  • Save theHamdiz/5a78e34f64a43f76296adac44185e7d6 to your computer and use it in GitHub Desktop.

Select an option

Save theHamdiz/5a78e34f64a43f76296adac44185e7d6 to your computer and use it in GitHub Desktop.
create a sample concern in rails ex. taggable concern
module Taggable
extend ActiveSupport::Concern
included do
has_many :taggings, as: :taggable, dependent: :destroy
has_many :tags, through: :taggings
end
def tag_names
tags.map(&:name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment