Sha256: f829762048385be8d9069ff75a609f0e79d507d046713af134ecdbfa5a333c66

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
formol-0.0.6 app/controllers/formol/admin/forums_controller.rb
formol-0.0.5 app/controllers/formol/admin/forums_controller.rb
formol-0.0.4 app/controllers/formol/admin/forums_controller.rb