Records not being returned

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.

On Jun 30, 2006, at 7:52 PM, Scott H. wrote:

@needs = Need.find(:all, :conditions => “fulfilled_date = ‘null’”)

@needs = Need.find(:all, :conditions => “fulfilled_date IS NULL”)

-Ezra

Ezra Z. wrote:

On Jun 30, 2006, at 7:52 PM, Scott H. wrote:

@needs = Need.find(:all, :conditions => “fulfilled_date = ‘null’”)

@needs = Need.find(:all, :conditions => “fulfilled_date IS NULL”)

-Ezra

Thank 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs