Module: Godmin::Resources::ResourceController

Extended by:
ActiveSupport::Concern
Includes:
BatchActions
Defined in:
lib/godmin/resources/resource_controller.rb,
lib/godmin/resources/resource_controller/batch_actions.rb

Defined Under Namespace

Modules: BatchActions

Instance Method Summary collapse

Instance Method Details

#createObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/godmin/resources/resource_controller.rb', line 43

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



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

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



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

def edit; end

#indexObject



24
25
26
27
28
29
30
# File 'lib/godmin/resources/resource_controller.rb', line 24

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

#newObject



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

def new; end

#showObject



32
33
34
35
36
37
# File 'lib/godmin/resources/resource_controller.rb', line 32

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

#updateObject



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

def update
  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