Class: Hicube::PagesController
Constant Summary
ApplicationController::FLASH_TYPES
Instance Method Summary
collapse
#after_sign_in_path_for, #notify, #notify_now
Instance Method Details
#create ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/controllers/hicube/pages_controller.rb', line 22
def create
logger.debug "Creating page with #{params}"
@page = Hicube::Page.new page_params
@page.seo_title = "#{app_name} - #{@page.title}" if (@page.seo_title.nil? or @page.seo_title.empty?)
@page.save!
respond_to do |format|
notify :notice, ::I18n.t('messages.resource.created',
:type => Hicube::Page.model_name.human,
:resource => @page
)
format.html { redirect_to action: :edit, id: @page }
end
rescue Mongoid::Errors::Validations => e
respond_to do |format|
notify_now :error, ::I18n.t('messages.resource.not_valid',
:type => Hicube::Page.model_name.human,
:errors => @page.errors.full_messages.to_sentence
)
format.html { render :action => :new, :status => 422 }
end
end
|
#destroy ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/controllers/hicube/pages_controller.rb', line 46
def destroy
@page.destroy
respond_to do |format|
notify :notice, ::I18n.t('messages.resource.destroyed',
:type => Hicube::Page.model_name.human,
:resource => @page
)
format.html { redirect_to action: :index }
end
rescue
respond_to do |format|
notify :error, ::I18n.t('messages.resource.not_valid',
:type => Hicube::Page.model_name.human,
:errors => @page.errors.full_messages.to_sentence
)
format.html { redirect_to action: :edit, id: @page }
end
end
|
#edit ⇒ Object
65
66
|
# File 'app/controllers/hicube/pages_controller.rb', line 65
def edit
end
|
#new ⇒ Object
68
69
|
# File 'app/controllers/hicube/pages_controller.rb', line 68
def new
end
|
#update ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'app/controllers/hicube/pages_controller.rb', line 71
def update
logger.debug "Updating Pages with #{params}"
@page.update_attributes page_params
@page.seo_title = "#{app_name} - #{@page.title}" if (@page.seo_title.nil? or @page.seo_title.empty?)
@page.save!
respond_to do |format|
notify :notice, ::I18n.t('messages.resource.updated',
:type => Hicube::Page.model_name.human,
:resource => @page
)
format.html { redirect_to action: :edit, id: @page }
end
rescue Mongoid::Errors::Validations => e
respond_to do |format|
notify_now :error, ::I18n.t('messages.resource.not_valid',
:type => Hicube::Page.model_name.human,
:errors => @page.errors.full_messages.to_sentence
)
format.html { render :action => :edit, id: @page, :status => 422 }
end
end
|