Re: has_many with nullable foreign_key?

Thorsten L
2006-10-27T07:17:17Z

something like:

@pages = Page.find :all, :conditions => ["site_id = ? OR site_id is
NULL",id]

:conditions takes a string for the SQL WHERE condition. The array i use
there, handles the espacing of the "id" value to prevent SQL
injection,
and then replaces "?" with the escaped value of id...


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---