Class: ZadokController

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

Instance Method Summary collapse

Instance Method Details

#createObject



25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/zadok_controller.rb', line 25

def create
  if resource.save
    flash.now[:success] = t("#{resource_name.pluralize}.create_success")
    flash.keep(:success)
    redirect_to url_for(controller: resource_name.pluralize, action: :index)
  else
    flash.now[:danger] = resource.errors.full_messages.join("<br />")
    render "zadok/new"
  end
end

#destroyObject



49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/zadok_controller.rb', line 49

def destroy
  if resource.destroy
    flash.now[:success] = t("#{resource_name.pluralize}.destroy_success")
    flash.keep(:success)
  else
    flash.now[:danger] = resource.errors.full_messages.join("<br />")
    flash.keep(:danger)
  end
  redirect_to url_for(controller: resource_name.pluralize, action: :index)
end

#editObject



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

def edit
  render "zadok/edit"
end

#indexObject



16
17
18
19
# File 'app/controllers/zadok_controller.rb', line 16

def index
  filter_and_paginate_resources!
  render "zadok/index"
end

#newObject



21
22
23
# File 'app/controllers/zadok_controller.rb', line 21

def new
  render "zadok/new"
end

#showObject



12
13
14
# File 'app/controllers/zadok_controller.rb', line 12

def show
  render "zadok/show"
end

#updateObject



40
41
42
43
44
45
46
47
# File 'app/controllers/zadok_controller.rb', line 40

def update
  if resource.update(resource_params)
    flash.now[:success] = t("#{resource_name.pluralize}.update_success")
  else
    flash.now[:danger] = resource.errors.full_messages.join("<br />")
  end
  render "zadok/edit"
end