Champs .. Coming here for the first time .. :) Actually i am searching for a string in an array using an exists like this .. Area.exists?(:name = whatEverName) But the crisis is that how can i call this case insensitively .. I mean how can i check that this name(whatEverName) is available or not in Area array case insensitively .. May be u guyz can find out other way than exists also .. Please float in your opinions .. -- Posted via http://www.ruby-forum.com/.
Area.exists?(:name => ''whatEverName''.downcase) -- Posted via http://www.ruby-forum.com/.
Sijo Kg wrote:> > Area.exists?(:name => ''whatEverName''.downcase)Nopes .. Not Working .. Actually (:name => area_name) whole gives me a string which is to be checked for existence .. So probably we people can not do any operations on area_name alone .. Correct .. q -- Posted via http://www.ruby-forum.com/.
O sorry here here you have to get the db records to be case insensitive If Area is just an array (Not clear) then can do Area.include?(''whatEverName''.downacase) If its a model name its field Area.find(:all).collect {|a| a.name.downcase}.include?(''whatEverName''.downacase) Sijo -- Posted via http://www.ruby-forum.com/.
If Area is an model object then you can put it in conditions itself as below Area.find :all :conditions => [''name = lower(?)'', area_name.down_case] Nayak On Fri, Jun 19, 2009 at 3:20 PM, Sijo Kg <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote:> > O sorry here here you have to get the db records to be case insensitive > If Area is just an array (Not clear) then can do > Area.include?(''whatEverName''.downacase) > If its a model name its field > Area.find(:all).collect {|a| > a.name.downcase}.include?(''whatEverName''.downacase) > > Sijo > -- > Posted via http://www.ruby-forum.com/. > > > >-- - NAYAK --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Vishwanath Nayak wrote:> If Area is an model object then you can put it in conditions itself as > below > Area.find :all :conditions => [''name = lower(?)'', area_name.down_case] > > Nayak > > On Fri, Jun 19, 2009 at 3:20 PM, Sijo Kg > <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>wrote: > >> Posted via http://www.ruby-forum.com/. >> >> > >> > > > -- > - NAYAKChamps .. Above both are not working .. May be u people are not getting me properly .. :) Sorry, Area is an model object .. I had tried these four .. But none of them are working fine for "Area.exists? (:name => area_name)" 1) Area.find(:all, :conditions => [''name = lower(?)'', area_name.downcase]) 2) Area.find (:all).collect{|a| a.name.downcase}.include?(area_name.downcase) 3) Area.find(:all, :conditions => "name LIKE ''%#{:name => area_name }''") 4) Area.exists?([''name LIKE ?'', "%#{:name => area_name}%"]) Any other way .. ? Thanks for yours response Champs .. Coming good .. :) -- Posted via http://www.ruby-forum.com/.
On Fri, Jun 19, 2009 at 12:08 PM, Hemant Bhargava<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 1) Area.find(:all, :conditions => [''name = lower(?)'', area_name.downcase]) >This really should be working. Check the SQL generated in the log file and test that directly against your database. I would then tweak the SQL statement until you find what''s working, then work it back into ActiveRecord Andrew Timberlake http://ramblingsonrails.com http://MyMvelope.com - The SIMPLE way to manage your savings
Andrew Timberlake wrote:> On Fri, Jun 19, 2009 at 12:08 PM, Hemant > Bhargava<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> 1) Area.find(:all, :conditions => [''name = lower(?)'', area_name.downcase]) >> > > This really should be working. Check the SQL generated in the log file > and test that directly against your database. > I would then tweak the SQL statement until you find what''s working, > then work it back into ActiveRecord > > Andrew Timberlake > http://ramblingsonrails.com > > http://MyMvelope.com - The SIMPLE way to manage your savingsDude .. Sql itself is not generating .. Actually what happens is i had given the creation of sql in if condition .. I mean if this matches then only save .. I''ll tell u people the whole scenerio .. Area is a model name .. Area.exists?(:name => area_name) .. area name is coming from mine textbox value and i am cheking it against to the records name of the area table .. fine .. Lets suppose now that my area table have a field Bangalore and mine value coming from textbox is bangalore or may be banGalore .. i mean whatever .. So how can i map this .. ? And also if m giving Bangalore value it get stored .. If this will map then only it''ll save to the database .. This is my question .. Float your opinions .. -- Posted via http://www.ruby-forum.com/.
Area.find :all :conditions => [''lower(name) like (?)'', area_name.down_case] -- Posted via http://www.ruby-forum.com/.
Sijo Kg wrote:> Area.find :all :conditions => [''lower(name) like (?)'', > area_name.down_case]Not Working .. :''( -- Posted via http://www.ruby-forum.com/.
Area.find :all, :conditions => [''lower(name) = ?'', area_name.down_case] On Fri, Jun 19, 2009 at 4:35 PM, Hemant Bhargava < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Sijo Kg wrote: > > Area.find :all :conditions => [''lower(name) like (?)'', > > area_name.down_case] > > Not Working .. :''( > -- > Posted via http://www.ruby-forum.com/. > > > >-- - NAYAK --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---