Sha256: f5d9beade63b2d1ebc28d7b03e25c12fa74540ee759db082dd08de605e8debe6

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

module Droom
  class GroupsController < Droom::EngineController
    respond_to :html, :js
    layout :no_layout_if_pjax

    before_filter :build_group, :only => [:new, :create]
    before_filter :get_group, :only => [:show, :edit, :update, :destroy]
    before_filter :get_groups, :only => :index

    def index
      respond_with @groups do |format|
        format.js {
          render :partial => 'droom/groups/groups'
        }
      end
    end

    def new
      respond_with @group
    end

    def show
      respond_with @group do |format|
        format.js {
          render :partial => 'droom/groups/group'
        }
      end
    end

    def edit
      respond_with @group
    end

    def update
      @group.update_attributes(params[:group])
      render :partial => 'group'
    end

    def create
      if @group.save
        render :partial => "created"
      else
        respond_with @group
      end
    end
    
    def destroy
      @group.destroy
      head :ok
    end

  protected

    def build_group
      @group = Droom::Group.new(params[:group])
    end

    def get_group
      @group = Droom::Group.find(params[:id])
    end

    def get_groups
      @groups = current_user.admin? ? Droom::Group.all : Droom::Group.visible_to(current_user)
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
droom-0.4.3 app/controllers/droom/groups_controller.rb
droom-0.4.2 app/controllers/droom/groups_controller.rb
droom-0.4.1 app/controllers/droom/groups_controller.rb