class ForumgroupsController < ApplicationController def index redirect_to forums_path end def show redirect_to forums_path + "#forums-#{params[:id]}" end def edit if admin? @group = Forumgroup.find(params[:id]) else flash[:alert] = "You are not allowed to edit forum groups." end end def update if admin? @group = Forumgroup.find(params[:id]) if @group.update_attributes(params[:forumgroup]) flash[:notice] = "Forum group updated" redirect_to @group else flash[:alert] = "Something went wrong" render :edit end else flash[:alert] = "You are not allowed to change forum groups" end end def new if admin? @group = Forumgroup.new else flash[:alert] = "You are not allowed to create forum groups." redirect_to forums_path end end def create if admin? @group = Forumgroup.new(params[:forumgroup]) if @group.save flash[:notice] = "Forum group created." redirect_to @group else flash[:alert] = "Something went wrong" render :new end else flash[:alert] = "You are not allowed to create forum groups." redirect_to forums_path end end end