Class: RailsBlogEngine::PostsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @post.author = current_user
  @post.publish
  if @post.save
    redirect_to(post_permalink_path(@post),
                :notice => "Post was successfully created.")
  else
    render :action => :new
  end
end

#editObject



34
35
# File 'app/controllers/rails_blog_engine/posts_controller.rb', line 34

def edit
end

#indexObject



8
9
10
11
12
13
# File 'app/controllers/rails_blog_engine/posts_controller.rb', line 8

def index
  respond_to do |format|
    format.html { @posts = @posts.page(params[:page]).per(5) }
    format.atom { @posts = @posts.limit(15) }
  end
end

#newObject



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

def new
end

#showObject



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

def show
  @comments = comments_to_display.order(:created_at)
  @comment = Comment.new {|c| c.post = @post }
end

#updateObject



37
38
39
40
41
42
43
44
45
# File 'app/controllers/rails_blog_engine/posts_controller.rb', line 37

def update
  @post.update_attributes(params[:post])
  if @post.save
    redirect_to(post_permalink_path(@post),
                :notice => "Post was successfully updated.")
  else
    render :action => :edit
  end
end