Skip to content

Instantly share code, notes, and snippets.

@ryana

ryana/controller.rb

Created Oct 14, 2009
Embed
What would you like to do?
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