Hi Experts, I''ve Model Called Categories. Id and name column and another model called contacts which has id, name, address, phone, city, location, neighbourhood and lanmark. i''ve implemeneted ferret. (it isnt a problem) in model for categories and contacts acts_as_ferret :remote => true my question is if i pass a value like this on controller value = "%jewellary%" @categories = Category.find_by_contents(value) @contacts = Contact.find_by_contents(value) I can get datas from categories. which i''ve already. but if i pass value as value = "%je%" @categories = Category.find_by_contents(value) @contacts = Contact.find_by_contents(value) i dont get any datas displayed. as far as i understood that ferret searches for whole string like jewellary. is there a way to by pass the search? Thanks in Advance. regards, Bala --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
yes...you can do Contact.find_by_sql([''SELECT * FROM contacts WHERE contents LIKE ?'', ''%''+je+''%'']) I think I may be a little out on the syntax...you can check it here: http://api.rubyonrails.org/ look for "find_by_sql" under "Methods" -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phil Tayo wrote:> > yes...you can do Contact.find_by_sql([''SELECT * FROM contacts WHERE > contents LIKE ?'', ''%''+je+''%'']) > > I think I may be a little out on the syntax...you can check it here: > http://api.rubyonrails.org/ look for "find_by_sql" under "Methods"Actually I think those single quotes should be double quotes, not sure if it makes a difference so that should be : Contact.find_by_sql(["SELECT * FROM contacts WHERE contents LIKE ?", "%"+je+"%"]) Also if you want to search for multiple search terms you use question marks in the SQL and declare all the variables at the end like this: ...["SELECT * FROM tablname WHERE column 1 = ? AND column2 LIKE ? AND column3 = ?", @variable1, "%"+@variable2+"%", @variable3] -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Phil, Thanks for the reply, but if i could use find_by_sql then whats the use of Ferret? Bala On Jan 23, 1:34 am, Phil Tayo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Phil Tayo wrote: > > > yes...you can do Contact.find_by_sql([''SELECT * FROM contacts WHERE > > contents LIKE ?'', ''%''+je+''%'']) > > > I think I may be a little out on the syntax...you can check it here: > >http://api.rubyonrails.org/look for "find_by_sql" under "Methods" > > Actually I think those single quotes should be double quotes, not sure > if it makes a difference so that should be : > Contact.find_by_sql(["SELECT * FROM contacts WHERE > contents LIKE ?", "%"+je+"%"]) > > Also if you want to search for multiple search terms you use question > marks in the SQL and declare all the variables at the end like this: > > ...["SELECT * FROM tablname WHERE column 1 = ? AND column2 LIKE ? AND > column3 = ?", @variable1, "%"+@variable2+"%", @variable3] > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ermmm good point! I wish I''d realised that earlier, might have saved me a bit of time... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bala, depending on how big your ferret index is, destroy it and then recreate it as it might be a problem in that. I ran into a similar problem about a month ago and I seem to recall that''s how I fixed it. On Jan 23, 2008 7:38 AM, Phil Tayo <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > ermmm good point! I wish I''d realised that earlier, might have saved me > a bit of time... > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Ryan, Thanks for the reply, you meant to say destroy the ferret plugin or the index? regards, Bala On Jan 23, 6:29 am, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Bala, depending on how big your ferret index is, destroy it and then > recreate it as it might be a problem in that. I ran into a similar problem > about a month ago and I seem to recall that''s how I fixed it. > > On Jan 23, 2008 7:38 AM, Phil Tayo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > > ermmm good point! I wish I''d realised that earlier, might have saved me > > a bit of time... > > -- > > Posted viahttp://www.ruby-forum.com/. > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bala wrote:> Hi Ryan, > > Thanks for the reply, you meant to say destroy the ferret plugin or > the index? > > regards, > Balathe index -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Phil On Jan 23, 2:42 pm, Phil Tayo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Bala wrote: > > Hi Ryan, > > > Thanks for the reply, you meant to say destroy the ferret plugin or > > the index? > > > regards, > > Bala > > the index > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phil and Ryan, Thanks for the reply. i got the answer just i replaced "%" to "*" value = value.gsub("%", "*") categories = Category.find_by_contents(value) its working perfectly. Thanks for the effort Guys. :) regards, Bala On Jan 23, 2:43 pm, Bala <mbb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks Phil > > On Jan 23, 2:42 pm, Phil Tayo <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > Bala wrote: > > > Hi Ryan, > > > > Thanks for the reply, you meant to say destroy the ferret plugin or > > > the index? > > > > regards, > > > Bala > > > the index > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---