Class: Sunrise::ManagerController

Inherits:
ApplicationController show all
Includes:
Utils::SearchWrapper
Defined in:
app/controllers/sunrise/manager_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



36
37
38
39
# File 'app/controllers/sunrise/manager_controller.rb', line 36

def create
  @record.update_attributes(model_params)
  respond_with(@record, :location => redirect_after_update(@record))
end

#destroyObject



52
53
54
55
# File 'app/controllers/sunrise/manager_controller.rb', line 52

def destroy
  @record.destroy
  respond_with(@record, :location => scoped_index_path)
end

#editObject



41
42
43
44
45
# File 'app/controllers/sunrise/manager_controller.rb', line 41

def edit
  respond_with(@record) do |format|
    format.html { render_with_scope } 
  end
end

#exportObject



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'app/controllers/sunrise/manager_controller.rb', line 57

def export
  @records = abstract_model.apply_scopes(params, false)
  
  respond_to do |format|
    format.xml  { render :xml => @records }
    format.json { render :json => @records }
    format.csv  { render abstract_model.export_options.merge(:csv => @records) }
    
    if defined?(Mime::XLSX)
      format.xlsx { render abstract_model.export_options.merge(:xlsx => @records) }
    end
  end
end

#indexObject



15
16
17
18
19
20
21
# File 'app/controllers/sunrise/manager_controller.rb', line 15

def index
  @records = abstract_model.apply_scopes(params)

  respond_with(@records) do |format|
    format.html { render_with_scope(abstract_model.current_list) }
  end
end

#mass_destroyObject



80
81
82
83
84
85
86
87
# File 'app/controllers/sunrise/manager_controller.rb', line 80

def mass_destroy
  abstract_model.destroy_all(params)
  
  respond_to do |format|
    format.html { redirect_to redirect_after_update }
    format.json { render :json => params }
  end
end

#newObject



29
30
31
32
33
34
# File 'app/controllers/sunrise/manager_controller.rb', line 29

def new
  @record.attributes = abstract_model.model_params
  respond_with(@record) do |format|
    format.html { render_with_scope } 
  end
end

#showObject



23
24
25
26
27
# File 'app/controllers/sunrise/manager_controller.rb', line 23

def show
  respond_with(@record) do |format|
    format.html { render_with_scope } 
  end
end

#sortObject



71
72
73
74
75
76
77
78
# File 'app/controllers/sunrise/manager_controller.rb', line 71

def sort
  abstract_model.update_sort(params)

  respond_to do |format|
    format.html { redirect_to redirect_after_update }
    format.json { render :json => params }
  end
end

#updateObject



47
48
49
50
# File 'app/controllers/sunrise/manager_controller.rb', line 47

def update
  @record.update_attributes(model_params)
  respond_with(@record, :location => redirect_after_update(@record))
end