Class: PostsController
Instance Method Summary
collapse
caches_page_with_cache_marker, #raise_not_found!
Instance Method Details
#index ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'app/controllers/posts_controller.rb', line 9
def index
@posts = Post.filter(params).per(params[:per])
if params[:q].blank? && params[:tag].present? && @posts.empty?
raise ActiveRecord::RecordNotFound, 'Posts not found'
end
respond_with @posts
end
|
#search ⇒ Object
19
20
21
22
23
24
|
# File 'app/controllers/posts_controller.rb', line 19
def search
params[:per] = 10 if params[:per].blank? || params[:per].to_i < 1
@posts = Post.filter(params).per(params[:per])
render :index
end
|
#show ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'app/controllers/posts_controller.rb', line 26
def show
@post = Post.past.find_by(slug: params[:id])
raise ActiveRecord::RecordNotFound, "Post #{params[:id]} not found" unless @post
@meta_record = @post
respond_with @post
end
|