Re: Adding SEARCH functionality to a website

sanjib dhar
Tue, 27 Oct 2009 12:33:57 -0000

IN model...user.rb.

acts_as_ferret({:fields => {:get_text_for_fields_to_index => {}}})



  def get_text_for_fields_to_index
    [self.first_name, self.last_name, self.login, self.email,
     self.basic_profile.about_me, self.basic_profile.city,
self.basic_profile.state, self.basic_profile.country,
     self.personal_profile.activities, self.personal_profile.interests,
self.personal_profile.movies,
     self.personal_profile.music, self.personal_profile.tv,
self.personal_profile.turn_ons,
     self.personal_profile.turn_offs ].join(" ").strip
  end


Inside controller..

def search
    @query = params[:query].to_s.strip
    conditions = ["users.is_test = ? and users.user_type != ?", false,
User::ANONYMOUS]
    @users = User.find_with_ferret(@query, {:per_page => @@items_per_page,
:page => params[:page]},  :conditions => conditions)
    @total = @users.total_hits
    @page_title = "Searched users for ''#{@query}'' -
fStation"
    @meta_desc = "Searched users for #{@query} - " +
@users.collect(&:display_fullname).join('','')
    render "jokes/search"
  end




On Tue, Oct 27, 2009 at 4:06 PM, RubyonRails_newbie <
craigwesty79-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:

>
> what have I missed?
>
> I''m new to ruby on rails, and followed the tutorial to set it up..
>
> What other config do I need???
>
> On 27 Oct, 10:35, sanjib dhar
<sanjibdhar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > We r using it for a decade!!!!!!!!!!
> >
> > On Tue, Oct 27, 2009 at 4:00 PM, sanjib dhar
<sanjibdhar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> >wrote:
> >
> >
> >
> > > use acts as ferret
> >
> > > On Tue, Oct 27, 2009 at 3:42 PM, RubyonRails_newbie <
> > > craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:
> >
> > >> Hi there,
> >
> > >> I’ve tried to implement ferret into my web application which
would be
> > >> used to search the various models and return results based on
the word
> > >> entered.
> >
> > >> I cant get this to work, and wondered if anyone uses any
other
> > >> searchable plugin for Ruby on Rails, and if so, what was
best?
> >
> > >> I don''t need anything specifically fancy – but
something that at least
> > >> returns me some results.
> >
> > >> Any Ideas?
> >
> > >> If anyone has had success using ferret – please check out:
> >
> >
>>http://groups.google.co.uk/group/rubyonrails-talk/browse_thread/threa.
> ..
> >
> > >> And see if you can help me out….
> >
> > >> Cheers- Hide quoted text -
> >
> > - Show quoted text -
> >
>

--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---