How do I find a record in my database with a column that is "null" or empty. Right now I am using: @folder = Folder.find(:all, :conditions => "folder_id IS NULL") Based on this query which is tested to work on my database: SELECT * FROM folders WHERE folder_id IS NULL; Ruby on rails does not return any error message, but when I call: @folder.id respectively, it returns the value of the object_id. It seems, that the value doesn''t exist, and it returns the object_id instead. Do anyone know a solution of this problem? -- 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 -~----------~----~----~----~------~----~------~--~---
On 15 Apr 2008, at 14:34, David Trasbo wrote:> @folder = Folder.find(:all, :conditions => "folder_id IS NULL") >...> > Ruby on rails does not return any error message, but when I call: > > @folder.id > > respectively, it returns the value of the object_id. It seems, that > the > value doesn''t exist, and it returns the object_id instead. >find :all returns an array of objects not a single object (so there you''re asking for the id of the array containing the results) Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> find :all returns an array of objects not a single object (so there > you''re asking for the id of the array containing the results)Thank you. I didn''t think of that. I''m using :first instead, it works. -- 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 -~----------~----~----~----~------~----~------~--~---