[refs #374] Add paginate restriction for API

This commit is contained in:
konstantin.grabar 2012-08-31 16:23:44 +04:00
parent 03986b7c21
commit 6229daf137
1 changed files with 8 additions and 0 deletions

View File

@ -1,3 +1,11 @@
# -*- encoding : utf-8 -*-
class Api::V1::BaseController < ApplicationController
before_filter :restrict_paginate, :only => :index
protected
def restrict_paginate
params[:per_page] = 30 if params[:per_page].blank? or params[:per_page].to_i < 1
params[:per_page] = 100 if params[:per_page].to_i >100
end
end