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
17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/js_admin/resources_controller.rb', line 17 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
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/js_admin/resources_controller.rb', line 38 def destroy @record.destroy = "#{@resource.singular_label} was deleted." respond_to do |format| format.turbo_stream do flash.now[:notice] = load_records end format.html { redirect_to resources_path(@resource.model_id), notice: } end end |
#edit ⇒ Object
27 28 |
# File 'app/controllers/js_admin/resources_controller.rb', line 27 def edit end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/js_admin/resources_controller.rb', line 6 def index load_records end |
#new ⇒ Object
13 14 15 |
# File 'app/controllers/js_admin/resources_controller.rb', line 13 def new @record = @resource.new_record end |
#show ⇒ Object
10 11 |
# File 'app/controllers/js_admin/resources_controller.rb', line 10 def show end |
#update ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/controllers/js_admin/resources_controller.rb', line 30 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 |