Class: PostsController
Instance Method Summary
collapse
#current_user, #signed_in?, #url
Instance Method Details
#index ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/ecrire/theme/template/controllers/posts_controller.rb', line 4
def index
@posts = posts.published.includes(:titles).order('published_at DESC').page(params[:page]).per(params[:per])
if params[:page] == 1
@latest = @posts.first
@posts = @posts.where.not(id: @latest.id)
end
@tags = Tag.all
super
end
|
#show ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/ecrire/theme/template/controllers/posts_controller.rb', line 14
def show
redirect_to :root and return if post.nil?
redirect_to :root and return unless post.published?
if post.titles.first != @title
redirect_to theme.post_path(post.year, post.month, post), status: :moved_permanently
end
@suggestions = Post.published.limit(5).where.not(id: post.id)
end
|