Skip to content

Instantly share code, notes, and snippets.

@peterdietz
Created March 17, 2011 16:37
Show Gist options
  • Save peterdietz/874637 to your computer and use it in GitHub Desktop.
Save peterdietz/874637 to your computer and use it in GitHub Desktop.
some screwy ruby code
scope = Contact.scoped({})
scope = scope.in_project(@project.id) if @project
scope = scope.visible unless @project
scope = scope.tagged_with(params[:tag]) unless params[:tag].blank?
scope = scope.scoped :conditions => cond.conditions
if pages
@contacts_pages = Paginator.new(self, scope.count, 20, params[:page])
offset = @contacts_pages.current.offset
limit = @contacts_pages.items_per_page
scope = scope.scoped :limit => limit, :offset => offset if @contacts_pages.count > 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment