Forum: Ruby on Rails Give me NIL or null results

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Berlin B. (Guest)
on 2006-05-03 20:56
(Received via mailing list)
with this post; with a query with multiple tables, I am trying to return
results that are null in one table; I am trying to do something like
this;

class NumbersFeedLink < ActiveRecord::Base
  has_many :numbers_sent_feed_link
end

class NumbersSentFeedLink < ActiveRecord::Base
  belongs_to :numbers_feed_link
end

     sent = NumbersFeedLink.find(:all,
                    :order => [ "created_on desc" ],
                    :limit => @max_links_send,
                    :conditions => [ "numbers_sent_feed_link == nil" ]
                    )


--
Berlin B.
(ramaza3 on freenode)
http://www.newspiritcompany.com
http://www.newspiritcompany.com/newforums
also checkout alpha version of botverse:
http://www.newspiritcompany.com:8086/universe_home
Robby R. (Guest)
on 2006-05-03 20:56
(Received via mailing list)
On Apr 30, 2006, at 1:45 PM, Berlin B. wrote:

> end
>
>     sent = NumbersFeedLink.find(:all,
>                    :order => [ "created_on desc" ],
>                    :limit => @max_links_send,
>                    :conditions => [ "numbers_sent_feed_link == nil" ]
>                    )
>

The :conditions options accepts SQL that matches your database
conventions.

In PostgreSQL you could do:

:conditions => [ 'numbers_sent_feed_link IS NULL' ]

Good luck!

Cheers,

Robby


Robby R.
Founder & Executive Director

PLANET ARGON, LLC
Ruby on Rails Development, Consulting & Hosting

www.planetargon.com
www.robbyonrails.com

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4968 [fax]
Nanyang Z. (Guest)
on 2007-01-18 16:23
Robby R. wrote:

>
> In PostgreSQL you could do:
>
> :conditions => [ 'numbers_sent_feed_link IS NULL' ]
>
It works in mysql too.
This topic is locked and can not be replied to.