hmmmm when I try and add: @users = User.paginate_by_contents(@search.query,
:total_entries => User.total_hits(@search.query), :page => params [:page], :per_page => 10) I get this in the browser: You have a nil object when you didn't expect it! The error occurred while evaluating nil.query Nothing seems to run through it step by step...... On 28 Oct, 20:07, sax <s...@livinginthepast.org> wrote: > Ah. The documentation is assuming an ActiveRecord find, not > acts_as_ferret > > google is your friend? > > http://www.google.com/search?client=safari&rls=en&q=acts_as_ferret+pa... > > On Oct 28, 11:35 am, RubyonRails_newbie <craigwest...@googlemail.com> > wrote: > > > > > Hmmm... I must be missing something.. > > > here's what I have so far: > > > def search > > > @title = "Search" > > if params[:q] > > query = params[:q] > > # First find the user hits... > > �...@users = User.find_with_ferret(query, :limit => :all) > > # ...then the subhits. > > infos = Info.find_with_ferret(query, :limit => :all) > > > # Now combine into one list of distinct users sorted by last > > name. > > hits = infos > > @users.concat(hits.collect { |hit| hit.user }).uniq! > > # Sort by last name (requires a spec for each user). > > @users.each { |user| user.info ||= Info.new } > > @users = @users.sort_by { |user| user.info.last_name } > > > end > > > At the moment, this returns results, but has no pagination > > > I'm not 100% what i'm meant to add and where, to allow it to paginate > > properly > > > On 28 Oct, 18:14, sax <s...@livinginthepast.org> wrote: > > > > You should not need to add anything to your models, unless you want to > > > change the default number of fetched results per model. > > > > In your controller, instead of doing > > > > @things = Thing.find(:all, :conditions => whatever) > > > > you can do this > > > > @things = Thing.paginate(:page => params[:page], :conditions => > > > whatever) > > > > In your view you add > > > > <%= will_paginate @things %> > > > > And it automatically adds the pagination links. If you look at the > > > HTML output in a browser, you should see the tags and classes used, so > > > that you can style them. > > > > It may get slightly more complicated if you're including search > > > strings, sorting or other conditions, but so long as you can get your > > > params to the controller and into a :condition, it should play nice. > > > > On Oct 28, 10:55 am, RubyonRails_newbie <craigwest...@googlemail.com> > > > wrote: > > > > > Sorry, > > > > > Has anyone managed to get the willl_paginate plugin to work? > > > > > The git hub site makes no sense, and the example isn't clear enough > > > > for me to know what im meant to be doing...... > > > > > ie: What exactly do I need to put in the user.rb file in models > > > > What goes in the controller > > > > and what goes in the view? > > > > > I am new to this and understand sometings, but this isn't too clear > > > > for a beginner.... > > > > > cheers > > > > > On 28 Oct, 15:04, Frederick Cheung <frederick.che...@gmail.com> wrote: > > > > > > On Oct 28, 1:56 pm, RubyonRails_newbie <craigwest...@googlemail.com> > > > > > wrote: > > > > > > > Hi there, > > > > > > > I have managed to overcome my search issue, and now I am able to > > > > > > return users successfully. > > > > > > > I am now trying to paginate the results, so only 10 are displayed on > > > > > > each page. > > > > > > > The paginate example in the RailsSpace book doesn’t work in my > > > > > > version > > > > > > of rails (2.3.3). So – my question is: > > > > > > > Has anyone had this issue, and if so how was it overcome? > > > > > > pagination was removed from rails in 2.0. Get the will_paginate > > > > > plugin. > > > > > > Fred > > > > > > > Or > > > > > > > Is there a simpler way to implement this to tidy the results up > > > > > > > Many Thanks > > > > > > > I'm not too hot with Ruby on Rails yet, so if anyone can help, in a > > > > > > simple explanation kinda way, that would be cool! :-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---