36 lines
816 B
Ruby
Executable File
36 lines
816 B
Ruby
Executable File
class ForumsController < ApplicationController
|
|
load_and_authorize_resource :category
|
|
load_and_authorize_resource :forum, :through => :category, :shallow => true
|
|
|
|
before_filter :check_for_cancel
|
|
|
|
def create
|
|
if @forum.save
|
|
flash[:notice] = "Forum was successfully created."
|
|
redirect_to forums_url
|
|
else
|
|
render :action => 'new'
|
|
end
|
|
end
|
|
|
|
def update
|
|
if @forum.update_attributes(params[:forum])
|
|
flash[:notice] = "Forum was updated successfully."
|
|
redirect_to forum_url(@forum)
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
if @forum.destroy
|
|
flash[:notice] = "Category was deleted."
|
|
redirect_to forums_url
|
|
end
|
|
end
|
|
|
|
def check_for_cancel
|
|
if params[:commit] == 'cancel'
|
|
redirect_to @forum.nil? ? forum_path(@forum) : forums_path
|
|
end
|
|
end
|
|
end
|