Class: OgAdminController
Overview
The Controller for the OgBrowser Admin module.
Class Method Summary
collapse
Instance Method Summary
collapse
current, mounted, replace_current
append_features
included
class_to_list, class_to_method, class_to_path, included
included
Class Method Details
.setup_template_root(path) ⇒ Object
32
33
34
35
|
# File 'lib/part/admin/og/controller.rb', line 32
def self.setup_template_root(path)
super
@template_root << File.join(File.dirname(__FILE__), 'template')
end
|
Instance Method Details
#create(name) ⇒ Object
71
72
73
74
|
# File 'lib/part/admin/og/controller.rb', line 71
def create(name)
klass = name_to_class(name)
@obj = klass.allocate
end
|
#delete(name, oid) ⇒ Object
108
109
110
111
112
|
# File 'lib/part/admin/og/controller.rb', line 108
def delete(name, oid)
klass = name_to_class(name)
klass.delete(oid)
redirect_to_referer
end
|
#delete_class(name) ⇒ Object
61
62
63
64
|
# File 'lib/part/admin/og/controller.rb', line 61
def delete_class(name)
name_to_class(name).delete_all
redirect_to_referer
end
|
#destroy_class(name) ⇒ Object
66
67
68
69
|
# File 'lib/part/admin/og/controller.rb', line 66
def destroy_class(name)
name_to_class(name).destroy
redirect_to_referer
end
|
#index ⇒ Object
37
38
39
|
# File 'lib/part/admin/og/controller.rb', line 37
def index
@classes = Og.manager.managed_classes.sort { |x, y| x.name <=> y.name }
end
|
#list(name) ⇒ Object
42
43
44
45
|
# File 'lib/part/admin/og/controller.rb', line 42
def list(name)
@klass = name_to_class(name)
@objects, @pager = paginate(@klass, :per_page => Scaffolding.per_page)
end
|
#read(name, oid) ⇒ Object
78
79
|
# File 'lib/part/admin/og/controller.rb', line 78
def read(name, oid)
end
|
#save ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/part/admin/og/controller.rb', line 87
def save
klass = name_to_class(request['object_class_name'].to_s)
if oid = request['oid']
obj = klass[oid.to_s]
obj.assign(request, :assign_relations => true, :force_boolean => true)
else
obj = klass.create
obj.assign(request, :assign_relations => true)
end
unless obj.valid?
flash.concat :ERRORS, obj.errors
redirect_to_referer
end
obj.save
redirect :list, :name, obj.class
end
|
#search(name) ⇒ Object
48
49
50
51
|
# File 'lib/part/admin/og/controller.rb', line 48
def search(name)
@klass = name_to_class(name)
@obj = @klass.allocate
end
|
#search_results ⇒ Object
54
55
56
57
|
# File 'lib/part/admin/og/controller.rb', line 54
def search_results
@klass = name_to_class(request.params.delete('object_class_name').to_s)
@objects, @pager = paginate(@klass.query_by_example(request.params), :per_page => Scaffolding.per_page)
end
|
#update(name, oid) ⇒ Object
81
82
83
84
|
# File 'lib/part/admin/og/controller.rb', line 81
def update(name, oid)
klass = name_to_class(name)
@obj = klass[oid]
end
|