Sha256: 00123b189ab51ba9b879a8ccaac3ef73d52c931f5fe402858a06fb4614f3eb2e
Contents?: true
Size: 875 Bytes
Versions: 1
Compression:
Stored size: 875 Bytes
Contents
require_dependency "my_forum/application_controller" module MyForum class WelcomeController < ApplicationController def index return @forum_categories = Category.includes(:forums) if current_user && current_user.is_admin? @forum_categories = Category.includes(:forums, :user_groups). reject{|category| (category.user_groups.map(&:name) & (current_user_groups)).blank? } # Don`r forget permissions available_forum_ids = MyForum::Forum.where(category_id: @forum_categories.map(&:id)).pluck(:id) @recent_topics = Topic.find_by_sql(" SELECT my_forum_topics.* FROM my_forum_topics JOIN my_forum_forums ON my_forum_forums.id = my_forum_topics.forum_id WHERE my_forum_forums.id IN (#{available_forum_ids.join(',')}) ORDER BY my_forum_topics.updated_at DESC limit 10 ") || [] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
my_forum-0.0.1.beta10 | app/controllers/my_forum/welcome_controller.rb |