Class: DmCms::PostsController

Inherits:
ApplicationController show all
Includes:
ApplicationHelper, DmCore::LiquidHelper, DmCore::RenderHelper, DmCore::UrlHelper
Defined in:
app/controllers/dm_cms/posts_controller.rb,
app/controllers/dm_cms/comments_controller.rb

Instance Method Summary collapse

Instance Method Details

#ajax_add_commentObject




29
30
31
32
# File 'app/controllers/dm_cms/posts_controller.rb', line 29

def ajax_add_comment
  @post.comments.create(:body => params[:comment][:body], :user_id => current_user.id) if current_user && !params[:comment][:body].blank?
  redirect_to :back
end

#ajax_delete_commentObject




48
49
50
51
52
53
# File 'app/controllers/dm_cms/posts_controller.rb', line 48

def ajax_delete_comment
  if is_admin?
    Comment.find(params[:id]).destroy
  end
  redirect_to :back and return
end

#showObject




17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/dm_cms/posts_controller.rb', line 17

def show
  @blogs        = CmsBlog.available_to_user(current_user)
  @recent_posts = CmsPost.where(cms_blog_id: @blogs.map(&:id)).includes(:cms_blog, :translations).published.order('published_on DESC').limit(5)
  @comments     = @post.comments.paginate page: page_number

  #--- set title / meta data
  content_for :page_title, @post.title
  set_meta description: @post.summary, "og:description" => sanitize_text(markdown(@post.summary, safe: false))
  set_meta "og:image" => site_asset_media_url(@post.featured_image) if @post.featured_image.present?
end