Class: Blogit::PostsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/blogit/posts_controller.rb

Overview

Handles requests for viewing Blogit::Posts

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from ApplicationController

blogit_conf, #blogit_conf

Instance Attribute Details

- (Object) post (readonly)

The current Blogit::Post being displayed.

Returns:

  • a Blogit::Post with id from params



9
10
11
# File 'app/controllers/blogit/posts_controller.rb', line 9

def post
  @post
end

- (ActiveRecord::Relation) posts (readonly)

The current Posts being displayed

Returns:

  • (ActiveRecord::Relation)

    for Post table



14
15
16
# File 'app/controllers/blogit/posts_controller.rb', line 14

def posts
  @posts
end

Instance Method Details

- (Object) index

Handles GET requests to /blogit/posts.html, /blogit/posts.xml, and /blogit/posts.rss Possible formats include:

"XML" - calls #set_posts_for_feed. "RSS" - calls #set_posts_for_feed. "HTML" - calls #set_posts_for_index_page.

Returns:

  • nil



27
28
29
30
31
32
33
# File 'app/controllers/blogit/posts_controller.rb', line 27

def index
  respond_to do |format|
    format.xml  { set_posts_for_feed }
    format.rss  { set_posts_for_feed }
    format.html { set_posts_for_index_page }
  end
end

- (Object) show

Handles GET requests to /blogit/posts/:id.html



36
37
38
# File 'app/controllers/blogit/posts_controller.rb', line 36

def show
  set_post
end

- (Object) tagged

Handles GET requests to /blogit/posts/tagged/:tag.html. Renders the index template with Posts tagged with tag in tag parameter



42
43
44
45
# File 'app/controllers/blogit/posts_controller.rb', line 42

def tagged
  set_posts_for_tagged_page
  render :index
end