Class: Blogit::PostsController

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

Instance Method Summary (collapse)

Methods inherited from ApplicationController

blogit_authenticate, blogit_cacher, blogit_conf, #blogit_conf, blogit_sweeper, #current_blogger, #this_blogger?

Instance Method Details

- (Object) create



43
44
45
46
47
48
49
50
# File 'app/controllers/blogit/posts_controller.rb', line 43

def create
  @post = current_blogger.blog_posts.new(params[:post])
  if @post.save
    redirect_to @post, notice: 'Blog post was successfully created.'
  else
    render action: "new"
  end
end

- (Object) destroy



61
62
63
64
65
# File 'app/controllers/blogit/posts_controller.rb', line 61

def destroy
  @post = current_blogger.blog_posts.find(params[:id])
  @post.destroy
  redirect_to posts_url, notice: "Blog post was successfully destroyed."
end

- (Object) edit



39
40
41
# File 'app/controllers/blogit/posts_controller.rb', line 39

def edit
  @post = current_blogger.blog_posts.find(params[:id])
end

- (Object) index



14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/blogit/posts_controller.rb', line 14

def index
  respond_to do |format|
    format.xml {
      @posts = Post.order('created_at DESC')
    }
    format.html {
      @posts = Post.for_index(params[:page])
    }
  end
end

- (Object) new



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

def new
  @post = current_blogger.blog_posts.new(params[:post])
end

- (Object) show



25
26
27
28
# File 'app/controllers/blogit/posts_controller.rb', line 25

def show
  @post    = Post.find(params[:id])
  @comment = @post.comments.new
end

- (Object) tagged



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

def tagged
  @posts = Post.for_index(params[:page]).tagged_with(params[:tag])
  render :index
end

- (Object) update



52
53
54
55
56
57
58
59
# File 'app/controllers/blogit/posts_controller.rb', line 52

def update
  @post = current_blogger.blog_posts.find(params[:id])
  if @post.update_attributes(params[:post])
    redirect_to @post, notice: 'Blog post was successfully updated.'
  else
    render action: "edit"
  end
end