Class: MongoidForums::Admin::ForumsController
- Inherits:
-
BaseController
- Object
- BaseController
- MongoidForums::Admin::ForumsController
- Defined in:
- app/controllers/mongoid_forums/admin/forums_controller.rb
Instance Method Summary collapse
-
#add_group ⇒ Object
Temporary Methods - Try Not To Cringe Too Much <3 ###.
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #remove_group ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#add_group ⇒ Object
Temporary Methods - Try Not To Cringe Too Much <3 ###
55 56 57 58 59 60 61 |
# File 'app/controllers/mongoid_forums/admin/forums_controller.rb', line 55 def add_group group = Group.find(params[:group][:id]) @forum.moderator_groups << group @forum.save redirect_to admin_forum_path(@forum) end |
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/mongoid_forums/admin/forums_controller.rb', line 16 def create @forum = Forum.new(forum_params) if @forum.save flash[:notice] = t("mongoid_forums.admin.forum.created") redirect_to [:admin, @forum] else flash.now.alert = t("mongoid_forums.admin.forum.not_created") render :action => "new" end end |
#destroy ⇒ Object
47 48 49 50 51 52 |
# File 'app/controllers/mongoid_forums/admin/forums_controller.rb', line 47 def destroy @forum = Forum.find(params[:id]) @forum.destroy flash[:notice] = t("mongoid_forums.admin.forum.deleted") redirect_to admin_forums_path end |
#edit ⇒ Object
32 33 34 |
# File 'app/controllers/mongoid_forums/admin/forums_controller.rb', line 32 def edit @forum = Forum.find(params[:id]) end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/mongoid_forums/admin/forums_controller.rb', line 8 def index @forums = Forum.all end |
#new ⇒ Object
12 13 14 |
# File 'app/controllers/mongoid_forums/admin/forums_controller.rb', line 12 def new @forum = Forum.new end |
#remove_group ⇒ Object
63 64 65 66 67 68 69 |
# File 'app/controllers/mongoid_forums/admin/forums_controller.rb', line 63 def remove_group group = Group.find(params[:group][:id]) @forum.moderator_groups.delete(group) @forum.save redirect_to admin_forum_path(@forum) end |
#show ⇒ Object
27 28 29 30 |
# File 'app/controllers/mongoid_forums/admin/forums_controller.rb', line 27 def show @forum = Forum.find(params[:id]) @groups = Group.all.where(moderator: true).select{ |group| !@forum.moderator_groups.include?(group) } end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/mongoid_forums/admin/forums_controller.rb', line 36 def update @forum = Forum.find(params[:id]) if @forum.update(forum_params) flash[:notice] = t("mongoid_forums.admin.forum.updated") redirect_to @forum else flash.now.alert = t("mongoid_forums.admin.forum.not_updated") render :action => "edit" end end |