Created
January 29, 2011 18:01
-
-
Save anarchivist/802055 to your computer and use it in GitHub Desktop.
Blacklight workaround BookmarksController for Postgres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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