Class: JSAdmin::ResourcesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/js_admin/resources_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/js_admin/resources_controller.rb', line 19

def create
  @record = @resource.new_record(resource_params)

  if @record.save
    redirect_to resource_path(@resource.model_id, @record), notice: "#{@resource.singular_label} was created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



40
41
42
43
# File 'app/controllers/js_admin/resources_controller.rb', line 40

def destroy
  @record.destroy
  redirect_to resources_path(@resource.model_id), notice: "#{@resource.singular_label} was deleted."
end

#editObject



29
30
# File 'app/controllers/js_admin/resources_controller.rb', line 29

def edit
end

#indexObject



6
7
8
9
10
# File 'app/controllers/js_admin/resources_controller.rb', line 6

def index
  @page = [ params.fetch(:page, 1).to_i, 1 ].max
  @records = @resource.records(page: @page)
  @total_count = @resource.count
end

#newObject



15
16
17
# File 'app/controllers/js_admin/resources_controller.rb', line 15

def new
  @record = @resource.new_record
end

#showObject



12
13
# File 'app/controllers/js_admin/resources_controller.rb', line 12

def show
end

#updateObject



32
33
34
35
36
37
38
# File 'app/controllers/js_admin/resources_controller.rb', line 32

def update
  if @record.update(resource_params)
    redirect_to resource_path(@resource.model_id, @record), notice: "#{@resource.singular_label} was updated."
  else
    render :edit, status: :unprocessable_entity
  end
end