V
V
Viktor Vsk2014-09-27 04:00:19
Ruby on Rails
Viktor Vsk, 2014-09-27 04:00:19

Rails pagination. How to access the original selection?

We have:

records = Record.search(params[:search]).page(params[:page]).per(20)

Is it possible to get a selection Record.search(params[:search])after a paginated selection?
Or, at least, what could be less perverse than:
records_before_paginate = Record.search(params[:search])
records = records_before_paginate.page(params[:page]).per(20)

Is it reasonable to create a not_paginated method that would cut limit, offset directly from the request? Or is it a very rare case when such an opportunity is needed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2014-09-27
@viktorvsk

There is nothing perverted here, just name the variable normally

search_scope = Record.search(params[:search])
records = search_scope.page(params[:page]).per(20)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question