Class: SolidusAdmin::ResourcesController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- SolidusAdmin::ResourcesController
show all
- Includes:
- ControllerHelpers::Search
- Defined in:
- app/controllers/solidus_admin/resources_controller.rb
Instance Method Summary
collapse
#component
Instance Method Details
#create ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/solidus_admin/resources_controller.rb', line 32
def create
@resource = resource_class.new(permitted_resource_params)
if @resource.save
flash[:notice] = t('.success')
redirect_to after_create_path, status: :see_other
else
page_component = new_component.new(@resource)
render_resource_form_with_errors(page_component)
end
end
|
#destroy ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'app/controllers/solidus_admin/resources_controller.rb', line 58
def destroy
@resource = resource_class.where(id: params[:id])
resource_class.transaction { @resource.destroy_all }
flash[:notice] = t('.success')
redirect_back_or_to after_destroy_path, status: :see_other
end
|
#edit ⇒ Object
44
45
46
|
# File 'app/controllers/solidus_admin/resources_controller.rb', line 44
def edit
render edit_component.new(@resource)
end
|
#index ⇒ Object
GET /index
Uses #set_paginated_resources to set @resources and a instance variable with the plural name of the resource.
Uses the geared_pagination gem to set @page for pagination.
21
22
23
24
25
|
# File 'app/controllers/solidus_admin/resources_controller.rb', line 21
def index
respond_to do |format|
format.html { render index_component.new(page: @page) }
end
end
|
#new ⇒ Object
27
28
29
30
|
# File 'app/controllers/solidus_admin/resources_controller.rb', line 27
def new
@resource = resource_class.new
render new_component.new(@resource)
end
|
#update ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/solidus_admin/resources_controller.rb', line 48
def update
if @resource.update(permitted_resource_params)
flash[:notice] = t('.success')
redirect_to after_update_path, status: :see_other
else
page_component = edit_component.new(@resource)
render_resource_form_with_errors(page_component)
end
end
|