On Sat, Jul 3, 2010 at 3:30 AM, bingo bob <[email protected]> wrote:
>
> Thanks to all, settled on this code in the end in case useful to anyone
> else - further tips appreciated

>    banner = BannerAdvert.first(:conditions => [ "published >= ?", 1],
> :order => "RAND()")

Even if you're currently only working with a single database, it might
be a good idea to abstract that last statement. Different DBs use a
different syntax, so for example I'd write that as

   :order => RANDOM

where RANDOM is set in an initializer based on the DB actually being
used, e.g. <http://pastie.org/1029327>

I work in a lot of "mixed" environments, so that may be more useful to
me than most people, but...

FWIW,
-- 
Hassan Schroeder ------------------------ [email protected]
twitter: @hassan

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to