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



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

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



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

def edit; end

#indexObject



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

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

#newObject



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

def new; end

#showObject



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

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

#updateObject



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

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