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.

Yields:

  • Yields #posts if called with a block (useful for calling super from subclasses)

Returns:

  • nil


29
30
31
32
33
34
35
36
# File 'app/controllers/blogit/posts_controller.rb', line 29

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
  yield(posts) if block_given?      
end

- (Object) show { ... }

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

Yields:

  • Yields #post if called with a block (useful for calling super from subclasses)


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

def show
  set_post
  yield post if block_given?
end

- (Object) tagged { ... }

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

Yields:

  • Yields #posts if called with a block (useful for calling super from subclasses)


50
51
52
53
54
# File 'app/controllers/blogit/posts_controller.rb', line 50

def tagged
  set_posts_for_tagged_page
  yield(posts) if block_given?      
  render :index
end