Class: WebAdmin::CrudController
Instance Method Summary
collapse
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/web_admin/crud_controller.rb', line 17
def create
@object = object_class.new(permitted_params)
if @object.save
flash[:notice] = I18n.t("flash.actions.create.notice", resource_name: I18n.t("activerecord.models.#{controller_name.singularize}"))
respond_with [controller_name]
else
render 'new'
end
end
|
#destroy ⇒ Object
42
43
44
45
46
47
|
# File 'app/controllers/web_admin/crud_controller.rb', line 42
def destroy
@object = object_class.find params[:id]
@object.destroy
flash[:notice] = I18n.t("flash.actions.destroy.notice", resource_name: I18n.t("activerecord.models.#{controller_name.singularize}"))
respond_with [controller_name]
end
|
#edit ⇒ Object
28
29
30
|
# File 'app/controllers/web_admin/crud_controller.rb', line 28
def edit
@object = object_class.find(params[:id]).localized
end
|
#index ⇒ Object
9
10
11
|
# File 'app/controllers/web_admin/crud_controller.rb', line 9
def index
@objects = object_class.all.order('id desc')
end
|
#new ⇒ Object
13
14
15
|
# File 'app/controllers/web_admin/crud_controller.rb', line 13
def new
@object = object_class.new
end
|
#update ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/web_admin/crud_controller.rb', line 32
def update
@object = object_class.find params[:id]
if @object.update_attributes(permitted_params)
flash[:notice] = I18n.t("flash.actions.update.notice", resource_name: I18n.t("activerecord.models.#{controller_name.singularize}"))
respond_with [controller_name]
else
render 'edit'
end
end
|