I want to know the number of ways in which I can fetch the data on a particular name from database, because I am getting invalid data, for the name with space such as "abc xyz".. It uses select *from names where name="abc-xyz", whch is fetching wrong information, so please help me.And essentially I want to search on name itself rather than ID. -- Posted via http://www.ruby-forum.com/.
I think you need to provide more information for us to understand the problem (for me to understand it anyway). Can you post the code you are using to search for name "abc xyz" which is being turned into a query "abc-xyz" as that is very odd. If you could post an extract from the code, an extract from the log showing the query, and the table structure then someone may be able to work out what the problem is. Colin 2009/5/23 Santosh Turamari <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > I want to know the number of ways in which I can fetch the data on a > particular name from database, because I am getting invalid data, for > the name with space such as "abc xyz".. It uses select *from names where > name="abc-xyz", whch is fetching wrong information, so please help > me.And essentially I want to search on name itself rather than ID. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Colin Law wrote:> I think you need to provide more information for us to understand the > problem (for me to understand it anyway). Can you post the code you are > using to search for name "abc xyz" which is being turned into a query > "abc-xyz" as that is very odd. If you could post an extract from the > code, > an extract from the log showing the query, and the table structure then > someone may be able to work out what the problem is. > > Colin > > 2009/5/23 Santosh Turamari <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>I am using this code. *********************************************************************** In application_helper return url_for :only_path => false,:controller => ''community'', :action => ''search_route'',:company =>((company.downcase.strip.squeeze(" ")).gsub(/[^[:alnum:]''&''''.''''!'']/,''-'')).squeeze("-").chomp("-"), :id => id ******************************************************************* In controller def search_route @query = " " if params[:company] != nil and params[:company] != "" @query = params[:company].strip #@query = "''\"#{@query}*\"''" @community = Community.find_by_name(@query) ..... ************************************************************ here @community is fetching wrong information. -- Posted via http://www.ruby-forum.com/.
On Sat, May 23, 2009 at 11:09 AM, Santosh Turamari <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I am using this code. > In application_helper > > return url_for :only_path => false,:controller => ''community'', :action > => ''search_route'',:company =>((company.downcase.strip.squeeze(" > ")).gsub(/[^[:alnum:]''&''''.''''!'']/,''-'')).squeeze("-").chomp("-"), :id => > idUh, you''re telling it to substitute a ''-'' for white-space in the name; if that''s not what you want, don''t do it :-) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Hassan Schroeder wrote:> On Sat, May 23, 2009 at 11:09 AM, Santosh Turamari > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > >> I am using this code. >> In application_helper >> >> return url_for :only_path => false,:controller => ''community'', :action >> => ''search_route'',:company =>((company.downcase.strip.squeeze(" >> ")).gsub(/[^[:alnum:]''&''''.''''!'']/,''-'')).squeeze("-").chomp("-"), :id => >> id > > Uh, you''re telling it to substitute a ''-'' for white-space in the name; > if > that''s not what you want, don''t do it :-) > > -- > Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.orgHi, Thanks for the reply.. Here my main problem is I want to have only space between two words. Here if I use only company.downcase.strip, then it is taking ''+''sign such as "abc+xyz".. I want it to be"abc xyz". Can I get the condition to produce the output of that kind.! -- Posted via http://www.ruby-forum.com/.
On Sat, May 23, 2009 at 12:49 PM, Santosh Turamari <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thanks for the reply.. Here my main problem is I want to have only > space between two words. Here if I use only company.downcase.strip, then > it is taking ''+''sign such as "abc+xyz".. I want it to be"abc xyz". Can I > get the condition to produce the output of that kind.!Look at your gsub; if you want a space instead of ''-'', it should be pretty obvious what to do :-) Open up irb and play with it a bit until you get the result you want: irb(main):001:0> ("abc xyz".gsub(/[^[:alnum:]''&''''.''''!'']/,''-'')).squeeze("-").chomp("-") => "abc-xyz" -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org