Skip to content

Instantly share code, notes, and snippets.

@jattoabdul
Last active May 13, 2019 21:36
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 jattoabdul/040a576e8d467fb6c27076a0f71e3540 to your computer and use it in GitHub Desktop.
Save jattoabdul/040a576e8d467fb6c27076a0f71e3540 to your computer and use it in GitHub Desktop.
Using Active Support Concerns
require 'activesupport/concern'
module Noteable
extend ActiveSupport::Concern
included do
has_many :notes, as: :noteable
end
def note_taking_action
# do stuff here
end
...
end
class Product < ActiveRecord::Base
include Noteable
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment