Class: Admin::ResourcesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/resources_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/admin/resources_controller.rb', line 10

def create
  @resource = resource_class.new(resource_params)
  authorize @resource

  if @resource.save
    redirect_to admin_resource_path
  else
    @resource = @resource.decorate
    render :new
  end
end

#destroyObject



41
42
43
44
45
# File 'app/controllers/admin/resources_controller.rb', line 41

def destroy
  if @resource.destroy
    redirect_to admin_resource_path, notice: t("deleted")
  end
end

#editObject



30
31
# File 'app/controllers/admin/resources_controller.rb', line 30

def edit
end

#indexObject



22
23
24
25
# File 'app/controllers/admin/resources_controller.rb', line 22

def index
  @resources = paginate resource_class.all
  @resource_class = resource_class
end

#newObject



5
6
7
8
# File 'app/controllers/admin/resources_controller.rb', line 5

def new
  @resource = resource_class.new.decorate
  authorize @resource
end

#showObject



27
28
# File 'app/controllers/admin/resources_controller.rb', line 27

def show
end

#updateObject



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

def update
  if @resource.update(resource_params)
    redirect_to action: :show
  else
    render 'edit'
  end
end