This repository has been archived on 2024-08-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
redstoner.com/app/controllers/forums_controller.rb
2013-10-16 00:51:50 +02:00

38 lines
864 B
Ruby

class ForumsController < ApplicationController
def index
redirect_to :forumgroups
end
def show
@forum = Forum.find(params[:id])
@threads = @forum.forumthreads
end
def new
if admin?
@group = Forumgroup.find(params[:forumgroup_id])
@forum = Forum.new(forumgroup: @group)
else
flash[:alert] = "You are not allowed to create a forum."
redirect_to forumgroups_path
end
end
def create
if admin?
@forum = Forum.new(params[:forum])
@forum.forumgroup = Forumgroup.find(params[:forumgroup_id])
if @forum.save
flash[:notice] = "Forum created."
redirect_to @forum
else
flash[:alert] = "Something went wrong"
render :new
end
else
flash[:alert] = "You are not allowed to create a forum."
redirect_to forums_path
end
end
end