module Formol class Admin::ForumsController < Admin::AdminController include Controllers::Nested::HasParentCategory respond_to :html, :except => [:reorganize] respond_to :js, :only => [:reorganize] def new forum respond_with(forum) end def create if forum.save respond_with(forum, :status => :created, :location => admin_categories_path) else respond_with(forum, :status => :unprocessable_entity) do |format| format.html { render :new } end end end def edit forum end def update if forum.update_attributes(params[:forum]) respond_with(forum, :location => admin_categories_path) else respond_with(forum) do |format| format.html { render :edit } end end end def destroy forum.destroy respond_with(forum, :location => admin_categories_path) end def reorganize Formol::Forum.reorganize(params[:forums], params[:category_id]) render :nothing => true, :status => :ok end protected def forum @forum ||= (params[:id].present? ? category.forums.find(params[:id]) : category.forums.new(params[:forum])) end end end