this confuses me... @zip = ZipCode.find(zip) where @zip is the first 3 digits of a zipcode the table is zipcodes the model zipcode so i understand @zip = Zipcode.find(zip) is attempting to look for zip in the zipcodes table via the model zipcode however i need to compare my 3 digit zip (@zip) againt two columns in the table column 1 - zipstart column 2 - endzip i need to find the row that my @zip falls inside the values of those two columns, so i believe this line of code is too simple example might be @zip = 034 startzip = 032 and endzip =037 in the table i need to identify that row can anyone help? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Nov 5, 2007, at 9:09 PM, agilehack wrote:> i need to find the row that my @zip falls inside the values of those > two columns, so i believe this line of code is too simple > > example might be @zip = 034 > startzip = 032 and endzip =037 in the table > i need to identify that row(inside class ZipCode) def self.find_between(zip) find(:first, :conditions => [''startzip <= ? AND endzip >= ?'', zip, zip]) end and in your controller @zip = ZipCode.find_between(zip) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---