Class: ActiveBlog::BlogPostsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/active_blog/blog_posts_controller.rb

Instance Method Summary collapse

Instance Method Details

#archivesObject



12
13
14
# File 'app/controllers/active_blog/blog_posts_controller.rb', line 12

def archives
  @blog_posts = BlogPost.all
end

#atomObject



35
36
37
38
39
40
# File 'app/controllers/active_blog/blog_posts_controller.rb', line 35

def atom
  @blog_posts = BlogPost.live.order('published_at DESC').limit(10)
  respond_to do |format|
    format.xml
  end
end

#indexObject



8
9
10
# File 'app/controllers/active_blog/blog_posts_controller.rb', line 8

def index
  @blog_posts = BlogPost.live.page(params[:page])
end

#previewObject



26
27
28
29
30
31
32
33
# File 'app/controllers/active_blog/blog_posts_controller.rb', line 26

def preview
  @blog_post = BlogPost.new(params[:active_blog_blog_post])
  @blog_post_partial = render_to_string(:partial => 'active_blog/active_admin/blog_post_show')

  respond_to do |format|
    format.js
  end
end

#showObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/active_blog/blog_posts_controller.rb', line 16

def show
  @blog_post = BlogPost.live.where(:cached_slug => params[:cached_slug]).first
  if @blog_post
    render
  else
    # TODO(mc): Should 404
    redirect_to active_blog_path, :notice => "No blog post with that URL"
  end
end