Skip to content

Instantly share code, notes, and snippets.

@anarchivist
Created January 29, 2011 18:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anarchivist/802055 to your computer and use it in GitHub Desktop.
Save anarchivist/802055 to your computer and use it in GitHub Desktop.
Blacklight workaround BookmarksController for Postgres
require_dependency( 'vendor/plugins/blacklight/app/controllers/bookmarks_controller.rb')
class BookmarksController < ApplicationController
def collection
user_id = current_user ? current_user.id : nil
assocations = nil
conditions = ['user_id = ?', user_id]
if params[:a] == 'find' && ! params[:q].blank?
q = "%#{params[:q]}%"
conditions.first << ' AND (tags.name LIKE ? OR title LIKE ? OR notes LIKE ?)'
conditions += [q, q, q]
assocations = [:tags]
end
# this differs from BL's default controller for bookmarks because it removes
# the order/group stuff. Hacky workaround for Postgres.
Bookmark.paginate_by_tag(params[:tag], :per_page => 8, :page => params[:page], :conditions => conditions, :include => assocations)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment