Skip to content

Instantly share code, notes, and snippets.

@drusepth
Last active June 4, 2020 02:37
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 drusepth/04f9f6655c4d60f8664684bfeefe7cfd to your computer and use it in GitHub Desktop.
Save drusepth/04f9f6655c4d60f8664684bfeefe7cfd to your computer and use it in GitHub Desktop.
lib/extensions/thredded/topic.rb
# lib/extensions/thredded/topic.rb
module Extensions
module Thredded
module Topic
extend ActiveSupport::Concern
included do
after_create :create_content_page_share
has_many :content_page_shares, as: :content
def self.icon
'forum'
end
def self.color
'blue'
end
end
def create_content_page_share
ContentPageShare.create(
user_id: self.user_id,
content_page_type: self.class.name,
content_page_id: self.id,
shared_at: self.created_at,
privacy: 'public',
message: self.title,
)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment