This code for my blog checks to see if tags are in the params hash. If they are, then only posts that are tagged will be paginated. Otherwise, all of the posts are paginated.
class PostsController < ApplicationController
def index
if params[:tag]
@posts = Post.tagged_with(params[:tag]).paginate(page: params[:page])
else
@posts = Post.all.paginate(page: params[:page])
end
end
end
I feel like this checking of params shouldn't be the concern of the controller, but of some other model like PostParameterChecker
. How do you feel about this? Where does this code actually belong?