indexing - Rails: Sunspot and Will_Paginate Issue -


i've hit snag college project regarding use of sunspot search gem , will_paginate. i've been using sunspot in project index controller , working fine when added pagination same index created problem. cant seem have both search , pagination @ same time.

this gives me pagination (see below):

def index

@projects = project.all @projects = project.paginate :per_page => 4, :page => params[:page] respond_to |format|   format.html # index.html.erb   format.json { render json: @projects } end 

end

this gives me search index (see below):

def index

@projects = project.all @search = project.search   fulltext params[:search] end @projects = @search.results respond_to |format|   format.html # index.html.erb   format.json { render json: @projects } end 

end

but when add pagination doesn't work/display (see below):

def index

@projects = project.paginate :per_page => 4, :page => params[:page] @search = project.search   fulltext params[:search] end @projects = @search.results respond_to |format|   format.html # index.html.erb   format.json { render json: @projects } end 

end

the search still works pagination doesn't appear... ideas how them both working together?

many thanks!

answering own question here, never occured me add in if , else separate actions in def index....

this works perfectly...

if params[:search] @search = project.search   fulltext params[:search] end   @projects = @search.results else @projects = project.all @projects = project.paginate(:page => params[:page], :per_page => 4) respond_to |format|   format.html # index.html.erb   format.json { render json: @projects } end 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -