Class: DcForumRenderer
- Inherits:
-
DcRenderer
- Object
- DcRenderer
- DcForumRenderer
- Includes:
- DcApplicationHelper
- Defined in:
- app/renderers/dc_forum_renderer.rb
Instance Method Summary collapse
-
#default ⇒ Object
Default method will list all available forums.
-
#topic ⇒ Object
Topic method lists topic and its replays.
-
#topics ⇒ Object
Topic method lists topic and its replays.
Instance Method Details
#default ⇒ Object
Default method will list all available forums
73 74 75 76 77 78 79 |
# File 'app/renderers/dc_forum_renderer.rb', line 73 def default return topic if @parent.params[:topic] return topics if @parent.params[:forum] # forums = DcForum.where(:site_id.in => [nil, dc_get_site._id], active: true).order(order: 1).each @parent.render partial: 'dc_forum/forums', formats: [:html], locals: { forums: forums, opts: @opts } end |
#topic ⇒ Object
Topic method lists topic and its replays.
Same as code above but with usage of view partial.
48 49 50 51 52 53 54 55 |
# File 'app/renderers/dc_forum_renderer.rb', line 48 def topic forum = DcForum.find(@parent.params[:forum]) topic = DcForumTopic.find(@parent.params[:topic]) replies = DcReply.where(doc_id: topic.id, active: true).order(created_at: 1) .page(@parent.params[:page]).per(15) @parent.render partial: 'dc_forum/topic', formats: [:html], locals: { forum: forum, topic: topic, replies: replies, opts: @opts } end |
#topics ⇒ Object
Topic method lists topic and its replays.
Same as code above but with usage of view partial.
62 63 64 65 66 67 68 |
# File 'app/renderers/dc_forum_renderer.rb', line 62 def topics forum = DcForum.find(@parent.params[:forum]) topics = DcForumTopic.only(:id, :created_by_name, :updated_by_name, :subject, :created_at, :updated_at, :replies) .where(dc_forum_id: forum._id, active: true).order(updated_at: -1) .page(@parent.params[:page]).per(10) @parent.render partial: 'dc_forum/topics', formats: [:html], locals: { forum: forum, topics: topics, opts: @opts } end |