Sha256: bda5462c81f1ba23689c3ec473effd95b5d5f932676e42f6530ce82fe5d77d28

Contents?: true

Size: 1.37 KB

Versions: 16

Compression:

Stored size: 1.37 KB

Contents

# Extends the User model with hooks for the Forum
#------------------------------------------------------------------------------
module DmForum
  module Concerns
    module User
      extend ActiveSupport::Concern

      # 'included do' causes the included code to be evaluated in the
      # conext where it is included (post.rb), rather than be 
      # executed in the module's context (blorgh/concerns/models/post).
      #------------------------------------------------------------------------------
      included do

        has_many :forum_comments, {:as => :commentable, :dependent => :delete_all}
        has_many :forum_topics, -> { order("#{ForumTopic.table_name}.created_at desc") }

        #------------------------------------------------------------------------------
        def available_forums
          @available_forums ||= site.ordered_forums - forums
        end
      end

      #------------------------------------------------------------------------------
      module ClassMethods
      end

    end
  end
end

# {todo} non-working attempts to include this automatically if the forum engine is being used,
# so that it doesn't have to be added to the application's user.rb file by hand
#------------------------------------------------------------------------------
# class User
#   include DmForum::Concerns::User
# end
# User.send :include, DmForum::Concerns::User

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dm_forum-4.2.3.10 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.3.9 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.3.8 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.3.7 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.3.6 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.3.5 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.3.4 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.3.3 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.3.2 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.3.1 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.3 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.2.3 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.2.2 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.2.1 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.2 app/models/dm_forum/concerns/user.rb
dm_forum-4.2.1.5 app/models/dm_forum/concerns/user.rb