Class: Madmin::ResourceController
Instance Method Summary
collapse
Methods included from SortHelper
#asc_icon, #default_sort_column, #default_sort_direction, #desc_icon, #sort_column, #sort_direction, #sortable
#authenticate_admin_user
Instance Method Details
#create ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'app/controllers/madmin/resource_controller.rb', line 31
def create
@record = resource.model.new(resource_params)
if @record.save
redirect_to resource.show_path(@record)
else
render :new, status: :unprocessable_entity
end
end
|
#destroy ⇒ Object
51
52
53
54
|
# File 'app/controllers/madmin/resource_controller.rb', line 51
def destroy
@record.destroy
redirect_to resource.index_path
end
|
#edit ⇒ Object
40
41
|
# File 'app/controllers/madmin/resource_controller.rb', line 40
def edit
end
|
#index ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/madmin/resource_controller.rb', line 10
def index
@pagy, @records = pagy(scoped_resources)
respond_to do |format|
format.html
format.json {
render json: @records.map { |r| {name: @resource.display_name(r), id: r.id} }
}
end
rescue Pagy::OverflowError
params[:page] = 1
retry
end
|
#new ⇒ Object
27
28
29
|
# File 'app/controllers/madmin/resource_controller.rb', line 27
def new
@record = resource.model.new
end
|
#show ⇒ Object
24
25
|
# File 'app/controllers/madmin/resource_controller.rb', line 24
def show
end
|
#update ⇒ Object
43
44
45
46
47
48
49
|
# File 'app/controllers/madmin/resource_controller.rb', line 43
def update
if @record.update(resource_params)
redirect_to resource.show_path(@record)
else
render :edit, status: :unprocessable_entity
end
end
|