Don't will_paginate json requests on people search

This commit is contained in:
Raphael Sofaer 2011-03-30 13:40:02 -07:00
parent e922ef8f22
commit 2d31d364f2

View file

@ -17,16 +17,24 @@ class PeopleController < ApplicationController
return
end
limit = params[:limit] || 15
limit = params[:limit] ? params[:limit].to_i : 15
@people = Person.search(params[:q], current_user).paginate :page => params[:page], :per_page => limit
@hashes = hashes_for_people(@people, @aspects) unless request.format == :json
respond_to do |format|
format.json do
@people = Person.search(params[:q], current_user).limit(limit)
render :json => @people
end
#only do it if it is an email address
if params[:q].try(:match, Devise.email_regexp)
webfinger(params[:q])
format.html do
@people = Person.search(params[:q], current_user).paginate :page => params[:page], :per_page => limit
@hashes = hashes_for_people(@people, @aspects)
#only do it if it is an email address
if params[:q].try(:match, Devise.email_regexp)
webfinger(params[:q])
end
end
end
respond_with @people
end
def hashes_for_people people, aspects