Class: ZadokController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ZadokController
- Defined in:
- app/controllers/zadok_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
39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/zadok_controller.rb', line 39 def create if resource.save flash.success(t("zadok.create.success", model: resource_name)) redirect_to url_for(controller: controller_name, action: :index) else resource.errors..each { || flash.danger() } render resource_template(:new) end end |
#destroy ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'app/controllers/zadok_controller.rb', line 62 def destroy if resource.destroy flash.success(t("zadok.destroy.success", model: resource_name)) else fresource.errors..each { || flash.danger() } end redirect_to url_for(controller: controller_name, action: :index) end |
#edit ⇒ Object
49 50 51 |
# File 'app/controllers/zadok_controller.rb', line 49 def edit render resource_template(:edit) end |
#index ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/zadok_controller.rb', line 15 def index respond_to do |format| format.csv { send_data(generate_csv) } format.html do filter_and_paginate_resources! render resource_template(:index) end format.json { render json: resources, root: false } format.xml { render xml: resources.map(&:attributes), root: controller_name } end end |
#new ⇒ Object
35 36 37 |
# File 'app/controllers/zadok_controller.rb', line 35 def new render resource_template(:new) end |
#show ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/controllers/zadok_controller.rb', line 27 def show respond_to do |format| format.html { render resource_template(:show) } format.json { render json: resource, root: false } format.xml { render xml: resource.attributes, root: controller_name.singularize } end end |
#update ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'app/controllers/zadok_controller.rb', line 53 def update if resource.update(resource_params) flash.success(t("zadok.update.success", model: resource_name)) else resource.errors..each { || flash.danger() } end render resource_template(:edit) end |