Class: Cambium::AdminController
Instance Method Summary
collapse
#admin, #admin_form, #admin_model, #admin_routes, #admin_table, #admin_view, #avatar, #cambium_form, #cambium_form_fields, #cambium_page_title, #cambium_route, #cambium_table, #can_delete?, #has_new_form?, #is_edit?, #is_index?, #not_found
Instance Method Details
#create ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'app/controllers/cambium/admin_controller.rb', line 39
def create
@object = admin_model.new(create_params)
if @object.save
redirect_to(admin_routes.index, :notice => "#{admin_model.to_s} created!")
else
render 'new'
end
end
|
#destroy ⇒ Object
61
62
63
64
65
|
# File 'app/controllers/cambium/admin_controller.rb', line 61
def destroy
set_object
@object.destroy
redirect_to(admin_routes.index, :notice => "#{admin_model.to_s} deleted!")
end
|
#edit ⇒ Object
48
49
50
|
# File 'app/controllers/cambium/admin_controller.rb', line 48
def edit
set_object
end
|
#index ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/cambium/admin_controller.rb', line 10
def index
respond_to do |format|
scope = admin_table.scope
if scope.split('.').size > 1
@collection = admin_model
scope.split('.').each do |s|
@collection = @collection.send(s)
end
else
@collection = admin_model.send(admin_table.scope)
end
format.html do
@collection = @collection.page(params[:page] || 1).per(15)
end
format.csv do
send_data admin.to_csv(@collection)
end
end
end
|
#new ⇒ Object
35
36
37
|
# File 'app/controllers/cambium/admin_controller.rb', line 35
def new
@object = admin_model.new
end
|
#show ⇒ Object
30
31
32
33
|
# File 'app/controllers/cambium/admin_controller.rb', line 30
def show
set_object
redirect_to(admin_routes.edit)
end
|
#update ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'app/controllers/cambium/admin_controller.rb', line 52
def update
set_object
if @object.update(update_params)
redirect_to(admin_routes.index, :notice => "#{admin_model.to_s} updated!")
else
render 'edit'
end
end
|