right now I have this in my controller:
def index
@votes = Vote.paginate(:page => params[:page], :order=>"created_at DESC")
end
but I’m considering moving the .paginate to the views/index.html.erb (or a partial in that directory). Paginate seems to me like it belongs in the View, as it manages how the Vote collection will be displayed. Am I understanding the MVC separation correctly?
No, you want it in the controller
#paginatealters your query so that it has a limit and a starting point.So if you have 100 records, your paginate with page 2 will call something liks
And it will only return 30 records. If you did the same in the view, your @votes would have 1000 records and chop off what’s needed.
Your view should be decently dumb and iterate over the records that the Controller gives it (which it gets from the model).