Created
April 23, 2016 22:18
-
-
Save theHamdiz/5a78e34f64a43f76296adac44185e7d6 to your computer and use it in GitHub Desktop.
create a sample concern in rails ex. taggable concern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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