Class: Cms::ResourceController
Instance Method Summary
collapse
allow_guests_to
#no_browser_caching
Instance Method Details
#create ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/cms/resource_controller.rb', line 14
def create
@object = build_object(resource_params)
if @object.save
flash[:notice] = "#{resource_name.singularize.titleize} '#{object_name}' was created"
redirect_to after_create_url
else
instance_variable_set("@#{variable_name}", @object)
if (params[:on_fail_action])
render :action => params[:on_fail_action]
else
render :action => 'new'
end
end
end
|
#destroy ⇒ Object
52
53
54
55
56
57
58
|
# File 'app/controllers/cms/resource_controller.rb', line 52
def destroy
@object = resource.find(params[:id])
if @object.destroy
flash[:notice] = "#{resource_name.singularize.titleize} '#{object_name}' was deleted"
end
redirect_to index_url
end
|
#edit ⇒ Object
33
34
35
|
# File 'app/controllers/cms/resource_controller.rb', line 33
def edit
instance_variable_set("@#{variable_name}", resource.find(params[:id]))
end
|
#index ⇒ Object
6
7
8
|
# File 'app/controllers/cms/resource_controller.rb', line 6
def index
instance_variable_set("@#{variable_name.pluralize}", resource.order(order_by_column))
end
|
#new ⇒ Object
10
11
12
|
# File 'app/controllers/cms/resource_controller.rb', line 10
def new
instance_variable_set("@#{variable_name}", build_object)
end
|
#show ⇒ Object
29
30
31
|
# File 'app/controllers/cms/resource_controller.rb', line 29
def show
instance_variable_set("@#{variable_name}", resource.find(params[:id]))
end
|
#update ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/cms/resource_controller.rb', line 37
def update
@object = resource.find(params[:id])
if @object.update(resource_params())
flash[:notice] = "#{resource_name.singularize.titleize} '#{object_name}' was updated"
redirect_to after_update_url
else
instance_variable_set("@#{variable_name}", @object)
if (params[:on_fail_action])
render :action => params[:on_fail_action]
else
render :action => 'edit'
end
end
end
|