Sha256: 7f2229a95b04c2bb2ffcfd953ee458eadfff02e2ca6d851d128cbb3387bbe9a2

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

module Droom
  class OrganisationsController < Droom::EngineController
    respond_to :html, :js
    layout :no_layout_if_pjax
    helper Droom::DroomHelper
  
    before_filter :authenticate_user!
    before_filter :get_people, :only => [:index]
    before_filter :find_organisations, :only => [:index]
    before_filter :get_organisation, :only => [:show, :edit, :update, :destroy]
    before_filter :build_organisation, :only => [:new, :create]

    def create
      @organisation.update_attributes(params[:organisation])
      respond_with @organisation
    end

    def update
      @organisation.update_attributes(params[:organisation])
      respond_with @organisation
    end

    def show
      respond_with @organisation
    end

    def destroy
      @organisation.destroy
      head :ok
    end

  protected

    def find_organisations
      @organisations = Droom::Organisation.order("name asc")
    end

    def get_people
      @show = params[:show] || 10
      @page = params[:page] || 1
      @people = Droom::Person.order("name asc").page(@page).per(@show)
    end
    
    def get_organisation
      @organisation = Droom::Organisation.find(params[:id])
    end

    def build_organisation
      @organisation = Droom::Organisation.new(params[:organisation])
    end
  
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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