Class: Admin::EventsController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/admin/events_controller.rb

Instance Method Summary collapse

Instance Method Details

#load_modelsObject



5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/admin/events_controller.rb', line 5

def load_models
  pp = pagination_parameters
  finder = @event_venue ? Event.at_venue(@event_venue) : Event.scoped({})
  unless params[:p]
    first_event = finder.future_and_current.first
    i = finder.index(first_event) || 0    # if there are no future events we revert to the first page
    p = (i / pp[:per_page].to_i) + 1
    pp[:page] = p if p && p > 1
  end
  self.models = finder.paginate(pp)
end