Module: Godmin::Resources::ResourceController

Extended by:
ActiveSupport::Concern
Defined in:
lib/godmin/resources/resource_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/godmin/resources/resource_controller.rb', line 40

def create
  respond_to do |format|
    if @resource_service.create_resource(@resource)
      format.html { redirect_to redirect_after_create, notice: redirect_flash_message }
      format.json { render :show, status: :created, location: @resource }
    else
      format.html { render :edit }
      format.json { render json: @resource.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject



68
69
70
71
72
73
74
75
# File 'lib/godmin/resources/resource_controller.rb', line 68

def destroy
  @resource_service.destroy_resource(@resource)

  respond_to do |format|
    format.html { redirect_to redirect_after_destroy, notice: redirect_flash_message }
    format.json { head :no_content }
  end
end

#editObject



38
# File 'lib/godmin/resources/resource_controller.rb', line 38

def edit; end

#indexObject



21
22
23
24
25
26
27
# File 'lib/godmin/resources/resource_controller.rb', line 21

def index
  respond_to do |format|
    format.html
    format.json
    format.csv
  end
end

#newObject



36
# File 'lib/godmin/resources/resource_controller.rb', line 36

def new; end

#showObject



29
30
31
32
33
34
# File 'lib/godmin/resources/resource_controller.rb', line 29

def show
  respond_to do |format|
    format.html
    format.json
  end
end

#updateObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/godmin/resources/resource_controller.rb', line 52

def update
  return if perform_batch_action

  set_resource

  respond_to do |format|
    if @resource_service.update_resource(@resource, resource_params)
      format.html { redirect_to redirect_after_update, notice: redirect_flash_message }
      format.json { render :show, status: :ok, location: @resource }
    else
      format.html { render :edit }
      format.json { render json: @resource.errors, status: :unprocessable_entity }
    end
  end
end