#671: removed restrict_paginate method

This commit is contained in:
Vokhmin Alexey V 2012-10-10 16:02:59 +04:00
parent e5c6707594
commit e6bb63db08
3 changed files with 6 additions and 9 deletions

View File

@ -3,7 +3,7 @@ class Api::V1::ArchesController < Api::V1::BaseController
before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] before_filter :authenticate_user! unless APP_CONFIG['anonymous_access']
def index def index
@arches = Arch.order(:id).all @arches = Arch.order(:id).paginate(paginate_params)
end end
end end

View File

@ -1,7 +1,6 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class Api::V1::BaseController < ApplicationController class Api::V1::BaseController < ApplicationController
before_filter :restrict_paginate, :only => :index
#respond_to :json #respond_to :json
rescue_from CanCan::AccessDenied do |exception| rescue_from CanCan::AccessDenied do |exception|
@ -12,13 +11,11 @@ class Api::V1::BaseController < ApplicationController
protected protected
def restrict_paginate
params[:per_page] = 30 if params[:per_page].to_i < 1
params[:per_page] = 100 if params[:per_page].to_i >100
end
def paginate_params def paginate_params
{:page => params[:page], :per_page => 20} per_page = params[:per_page].to_i
per_page = 20 if per_page < 1
per_page = 100 if per_page >100
{:page => params[:page], :per_page => per_page}
end end
def validation_failed(subject) def validation_failed(subject)

View File

@ -10,7 +10,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
def index def index
filter = BuildList::Filter.new(nil, current_user, params[:filter] || {}) filter = BuildList::Filter.new(nil, current_user, params[:filter] || {})
@build_lists = filter.find.scoped(:include => [:save_to_platform, :project, :user, :arch]) @build_lists = filter.find.scoped(:include => [:save_to_platform, :project, :user, :arch])
@build_lists = @build_lists.recent.paginate :page => params[:page], :per_page => params[:per_page] @build_lists = @build_lists.recent.paginate(paginate_params)
end end
def create def create