[#330] small refactoring

This commit is contained in:
Alexander Machehin 2014-09-30 21:10:06 +06:00
parent 89f322cd24
commit 2bca1f441c
1 changed files with 8 additions and 7 deletions

View File

@ -16,13 +16,14 @@ class Search
protected
def find_collection(type, term, ability, paginate_params)
if type == 'users'
User.opened
else
type.classify.constantize.accessible_by(ability, :read)
end.search(term).
search_order.
paginate(paginate_params)
scope = if type == 'users'
User.opened
else
type.classify.constantize.accessible_by(ability, :read)
end
scope.search(term).
search_order.
paginate(paginate_params)
end
end
end