Class: Blogit::PostsController
- Inherits:
-
ApplicationController
show all
- Defined in:
- app/controllers/blogit/posts_controller.rb
Overview
Using explicit ::Blogit::ApplicationController fixes NoMethodError
'blogit_authenticate' in the main_app
Instance Method Summary
(collapse)
blogit_authenticate, blogit_cacher, blogit_conf, #blogit_conf, blogit_sweeper, #current_blogger, #this_blogger?
Instance Method Details
- (Object) create
48
49
50
51
52
53
54
55
|
# File 'app/controllers/blogit/posts_controller.rb', line 48
def create
@post = current_blogger.blog_posts.new(params[:post])
if @post.save
redirect_to @post, notice: t(:blog_post_was_successfully_created, scope: 'blogit.posts')
else
render action: "new"
end
end
|
- (Object) destroy
66
67
68
69
70
|
# File 'app/controllers/blogit/posts_controller.rb', line 66
def destroy
@post = current_blogger.blog_posts.find(params[:id])
@post.destroy
redirect_to posts_url, notice: t(:blog_post_was_successfully_destroyed, scope: 'blogit.posts')
end
|
- (Object) edit
44
45
46
|
# File 'app/controllers/blogit/posts_controller.rb', line 44
def edit
@post = current_blogger.blog_posts.find(params[:id])
end
|
- (Object) index
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/blogit/posts_controller.rb', line 17
def index
respond_to do |format|
format.xml {
@posts = Post.order('created_at DESC')
}
format.html {
@posts = Post.for_index(params[:page])
}
format. {
@posts = Post.order('created_at DESC')
}
end
end
|
- (Object) new
40
41
42
|
# File 'app/controllers/blogit/posts_controller.rb', line 40
def new
@post = current_blogger.blog_posts.new(params[:post])
end
|
- (Object) show
31
32
33
|
# File 'app/controllers/blogit/posts_controller.rb', line 31
def show
@post = Post.find(params[:id])
end
|
- (Object) tagged
35
36
37
38
|
# File 'app/controllers/blogit/posts_controller.rb', line 35
def tagged
@posts = Post.for_index(params[:page]).tagged_with(params[:tag])
render :index
end
|
- (Object) update
57
58
59
60
61
62
63
64
|
# File 'app/controllers/blogit/posts_controller.rb', line 57
def update
@post = current_blogger.blog_posts.find(params[:id])
if @post.update_attributes(params[:post])
redirect_to @post, notice: t(:blog_post_was_successfully_updated, scope: 'blogit.posts')
else
render action: "edit"
end
end
|