Class: ZadokController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/zadok_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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.full_messages.each { |message| flash.danger(message) }
    render resource_template(:new)
  end
end

#destroyObject



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.full_messages.each { |message| flash.danger(message) }
  end
  redirect_to url_for(controller: controller_name, action: :index)
end

#editObject



49
50
51
# File 'app/controllers/zadok_controller.rb', line 49

def edit
  render resource_template(:edit)
end

#indexObject



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

#newObject



35
36
37
# File 'app/controllers/zadok_controller.rb', line 35

def new
  render resource_template(:new)
end

#showObject



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

#updateObject



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.full_messages.each { |message| flash.danger(message) }
  end
  render resource_template(:edit)
end