Module: Godmin::Resource
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/godmin/resource.rb,
lib/godmin/resource/scopes.rb,
lib/godmin/resource/filters.rb,
lib/godmin/resource/ordering.rb,
lib/godmin/resource/pagination.rb,
lib/godmin/resource/batch_actions.rb
Defined Under Namespace
Modules: BatchActions, Filters, Ordering, Pagination, Scopes
Instance Method Summary
collapse
Instance Method Details
Gives the view access to the list of attributes to be included in the default form
102
103
104
|
# File 'lib/godmin/resource.rb', line 102
def attrs_for_form
[]
end
|
#attrs_for_index ⇒ Object
Gives the view access to the list of column names to be printed in the index view
96
97
98
|
# File 'lib/godmin/resource.rb', line 96
def attrs_for_index
[]
end
|
#create ⇒ Object
79
80
81
82
|
# File 'lib/godmin/resource.rb', line 79
def create
@resource = resource_class.create(resource_params)
respond_with(@resource)
end
|
#destroy ⇒ Object
89
90
91
92
|
# File 'lib/godmin/resource.rb', line 89
def destroy
@resource.destroy
respond_with(@resource)
end
|
#edit ⇒ Object
75
76
77
|
# File 'lib/godmin/resource.rb', line 75
def edit
respond_with(@resource)
end
|
#index ⇒ Object
63
64
65
|
# File 'lib/godmin/resource.rb', line 63
def index
respond_with(@resources)
end
|
#new ⇒ Object
71
72
73
|
# File 'lib/godmin/resource.rb', line 71
def new
respond_with(@resource)
end
|
#resource ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/godmin/resource.rb', line 55
def resource
if params[:id]
resources_relation.find(params[:id])
else
resources_relation.new
end
end
|
#resource_class ⇒ Object
35
36
37
|
# File 'lib/godmin/resource.rb', line 35
def resource_class
controller_name.classify.constantize
end
|
#resources ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/godmin/resource.rb', line 43
def resources
(
apply_order(
apply_filters(
apply_scope(
resources_relation
)
)
)
)
end
|
#resources_relation ⇒ Object
39
40
41
|
# File 'lib/godmin/resource.rb', line 39
def resources_relation
resource_class.all
end
|
#show ⇒ Object
67
68
69
|
# File 'lib/godmin/resource.rb', line 67
def show
respond_with(@resource)
end
|
#update ⇒ Object
84
85
86
87
|
# File 'lib/godmin/resource.rb', line 84
def update
@resource.update(resource_params)
respond_with(@resource)
end
|