Class: Munificent::Admin::BundlesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/munificent/admin/bundles_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
# File 'app/controllers/munificent/admin/bundles_controller.rb', line 22

def create
  if @bundle.save
    flash[:notice] = "Bundle created"
    redirect_to edit_bundle_path(@bundle)
  else
    flash[:alert] = @bundle.errors.full_messages.join(", ")
    redirect_to new_bundle_path
  end
end

#destroyObject



45
46
47
48
# File 'app/controllers/munificent/admin/bundles_controller.rb', line 45

def destroy
  @bundle.destroy
  redirect_to bundles_path
end

#editObject



16
17
18
19
20
# File 'app/controllers/munificent/admin/bundles_controller.rb', line 16

def edit
  @bundle.bundle_tiers.build(
    price_currency: @bundle.fundraiser.main_currency,
  )
end

#indexObject



9
# File 'app/controllers/munificent/admin/bundles_controller.rb', line 9

def index; end

#newObject



12
13
14
# File 'app/controllers/munificent/admin/bundles_controller.rb', line 12

def new
  @bundle.bundle_tiers.build
end

#showObject



10
# File 'app/controllers/munificent/admin/bundles_controller.rb', line 10

def show; end

#updateObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/munificent/admin/bundles_controller.rb', line 32

def update
  @bundle.assign_attributes(bundle_params)
  @bundle.bundle_tiers = @bundle.bundle_tiers.compact_blank

  if @bundle.save
    flash[:notice] = "Bundle saved"
  else
    flash[:alert] = @bundle.errors.full_messages.join(", ")
  end

  redirect_to edit_bundle_path(@bundle)
end