I have the following line of code in my controller''s action method: @needs = Need.find(:all, :conditions => "fulfilled_date = ''null''") This returns no records to the view, but I am expecting one record. The following line in MySQL will return the record I expect: Select * from needs where fulfilled_date is null; To test the code, I substituted :conditions => "id = ''1''" and this did return a record. That was to test the general validity of the code. So I tried changing ''null'' to '''' and to ''nil'' Nothing. Also tried changing = to is, which caused a syntax error. Not finding an explicit example in my books, I resorted to trying everything I could think of. Nothing worked, which brings me here. Being new at this, I''m missing something (obviously). Was hoping someone might point out what that is (which is not obvious). Any help is of course much appreciated. -- Posted via http://www.ruby-forum.com/.
On Jun 30, 2006, at 7:52 PM, Scott Helfrich wrote:> @needs = Need.find(:all, :conditions => "fulfilled_date = ''null''")@needs = Need.find(:all, :conditions => "fulfilled_date IS NULL") -Ezra -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060701/7ebed4ba/attachment.html
Ezra Zygmuntowicz wrote:> On Jun 30, 2006, at 7:52 PM, Scott Helfrich wrote: > >> @needs = Need.find(:all, :conditions => "fulfilled_date = ''null''") > > @needs = Need.find(:all, :conditions => "fulfilled_date IS NULL") > > -EzraThank you Ezra. Yes, this worked! It did occur to me just this morning before checking back here at the forum, that the single quotes around null should not be, but I still didn''t have it right. Very much appreciated. Scott -- Posted via http://www.ruby-forum.com/.