Class: JSAdmin::ResourcesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- JSAdmin::ResourcesController
- Defined in:
- app/controllers/js_admin/resources_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
29 30 |
# File 'app/controllers/js_admin/resources_controller.rb', line 29 def edit end |
#index ⇒ Object
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 |
#new ⇒ Object
15 16 17 |
# File 'app/controllers/js_admin/resources_controller.rb', line 15 def new @record = @resource.new_record end |
#show ⇒ Object
12 13 |
# File 'app/controllers/js_admin/resources_controller.rb', line 12 def show end |
#update ⇒ Object
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 |