Sha256: aef0f738f2e167e98167f8c69b462b77053abb837f7ac9657b128fe4cfc4a110

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

module CitizenBudgetModel
  class OrganizationsController < CitizenBudgetModelController
    before_action :authenticate_user!
    before_action :check_authorization!
    before_action :set_organization, only: [:show, :edit, :update, :destroy]

    def index
      @organizations = Organization.all.sort_by(&:name)
    end

    def show
    end

    def new
      @organization = Organization.new
    end

    def edit
    end

    def create
      @organization = Organization.new(organization_params)

      if @organization.save
        redirect_to @organization, notice: _('Organization was created.')
      else
        render :new
      end
    end

    def update
      if @organization.update(organization_params)
        redirect_to @organization, notice: _('Organization was updated.')
      else
        render :edit
      end
    end

    def destroy
      @organization.destroy
      redirect_to organizations_path, notice: _('Organization was deleted.')
    end

  private

    def set_organization
      @organization = Organization.find(params[:id])
    end

    def organization_params
      params.require(:organization).permit(*Organization.globalize_attribute_names)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
citizen_budget_model-0.0.4 app/controllers/citizen_budget_model/organizations_controller.rb
citizen_budget_model-0.0.3 app/controllers/citizen_budget_model/organizations_controller.rb
citizen_budget_model-0.0.2 app/controllers/citizen_budget_model/organizations_controller.rb
citizen_budget_model-0.0.1 app/controllers/citizen_budget_model/organizations_controller.rb