Class: DmCms::Admin::CmsPostsController
- Inherits:
-
AdminController
- Object
- AdminController
- DmCms::Admin::CmsPostsController
- Includes:
- PermittedParams
- Defined in:
- app/controllers/dm_cms/admin/cms_posts_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
——————————————————————————.
-
#destroy ⇒ Object
——————————————————————————.
-
#edit ⇒ Object
——————————————————————————.
-
#new ⇒ Object
——————————————————————————.
-
#send_notifications_emails ⇒ Object
——————————————————————————.
-
#update ⇒ Object
——————————————————————————.
Methods included from PermittedParams
#cms_blog_params, #cms_contentitem_params, #cms_page_params, #cms_post_params, #cms_snippet_params, #media_file_params
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/dm_cms/admin/cms_posts_controller.rb', line 19 def create :manage_content, @blog @post = @blog.posts.new(cms_post_params) if @post.save redirect_to admin_cms_blog_url(@blog), notice: 'Post was successfully created.' else render action: :new end end |
#destroy ⇒ Object
41 42 43 44 45 |
# File 'app/controllers/dm_cms/admin/cms_posts_controller.rb', line 41 def destroy :manage_content, @blog @post.destroy redirect_to admin_cms_blog_url(@blog), notice: 'Post was successfully deleted.' end |
#edit ⇒ Object
14 15 16 |
# File 'app/controllers/dm_cms/admin/cms_posts_controller.rb', line 14 def edit :manage_content, @blog end |
#new ⇒ Object
8 9 10 11 |
# File 'app/controllers/dm_cms/admin/cms_posts_controller.rb', line 8 def new :manage_content, @blog @post = @blog.posts.build(comments_allowed: @blog.comments_allowed) end |
#send_notifications_emails ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/dm_cms/admin/cms_posts_controller.rb', line 48 def send_notifications_emails :manage_content, @blog status = @post.send_notification_emails(params[:test] ? current_user : nil) if params[:test] && status == 0 redirect_to admin_cms_blog_url(@blog), error: "Unable to send test email" else msg = params[:test] ? "Test notification sent to #{current_user.email}" : "#{status} emails are being sent" redirect_to admin_cms_blog_url(@blog), notice: msg end end |
#update ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/controllers/dm_cms/admin/cms_posts_controller.rb', line 31 def update :manage_content, @blog if @post.update_attributes(cms_post_params) redirect_to admin_cms_blog_url(@blog), notice: 'Post was successfully updated.' else render action: :edit end end |