Class: OrganizationsController

Inherits:
ApplicationController show all
Includes:
Applicat::Mvc::Controller::Resource
Defined in:
app/controllers/organizations_controller.rb

Instance Method Summary collapse

Methods included from Applicat::Mvc::Controller::Resource

included

Methods inherited from ApplicationController

#current_ability

Methods included from Voluntary::V1::BaseController

#parent, #voluntary_application_javascripts, #voluntary_application_stylesheets

Methods included from Applicat::Mvc::Controller

included

Instance Method Details

#createObject



29
30
31
32
33
34
35
36
37
# File 'app/controllers/organizations_controller.rb', line 29

def create
  @organization = current_user.organizations.new(params[:organization])
  
  if @organization.save
    redirect_to @organization, notice: t('general.form.successfully_created')
  else
    render :new
  end
end

#destroyObject



50
51
52
53
# File 'app/controllers/organizations_controller.rb', line 50

def destroy
  @organization.destroy
  redirect_to organizations_url, notice: t('general.form.destroyed')
end

#editObject



39
40
# File 'app/controllers/organizations_controller.rb', line 39

def edit
end

#indexObject



12
13
14
15
16
17
18
19
20
# File 'app/controllers/organizations_controller.rb', line 12

def index
  @parent = find_parent Organization::PARENT_TYPES
  @organizations = @parent ? @parent.organizations.order(:name) : Organization.order(:name)
  
  respond_to do |format|
    format.html
    format.json { render json: @organizations.tokens(params[:q]) }
  end
end

#newObject



25
26
27
# File 'app/controllers/organizations_controller.rb', line 25

def new
  @organization = Organization.new
end

#resourceObject



55
56
57
# File 'app/controllers/organizations_controller.rb', line 55

def resource
  @organization
end

#showObject



22
23
# File 'app/controllers/organizations_controller.rb', line 22

def show
end

#updateObject



42
43
44
45
46
47
48
# File 'app/controllers/organizations_controller.rb', line 42

def update
  if @organization.update_attributes(params[:organization])
    redirect_to @organization, notice: t('general.form.successfully_updated')
  else
    render :edit
  end
end