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
13
14
15
|
# 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])
@tags = Tag.all
respond_to do |format|
format.html
format.
format.json do
['Access-Control-Allow-Origin'] = '*'
end
end
end
|
#show ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/ecrire/theme/template/controllers/posts_controller.rb', line 17
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
|