Skip to content

Instantly share code, notes, and snippets.

@ryana
Created October 14, 2009 18:25
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 ryana/210295 to your computer and use it in GitHub Desktop.
Save ryana/210295 to your computer and use it in GitHub Desktop.
Using ThinkingSphinx in ActiveScaffold, but the pagination links dont get created properly
class Admin::PostController < AdminController
active_scaffold :post do |config|
config.action_links.add 'sphinx_search', :label => 'Search'
config.actions.exclude :search
CRU_COLUMNS = [:name, :content]
config.list.columns = CRU_COLUMNS
config.create.columns = CRU_COLUMNS
config.update.columns = CRU_COLUMNS
end
def sphinx_search
if request.post?
per_page = 20
@results = Post.search(params[:search_term], :per_page => per_page, :page => params[:page])
results = lambda {@results}
@page = Paginator.new(@results.total_entries, per_page, &results).first
@records = @page.items
render :action => 'list'
return
end
render :layout => false
end
end
<% form_tag :action => 'sphinx_search' do %>
<%= text_field_tag 'search_term' %>
<%= submit_tag 'Search' %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment