On 23.4.2008, at 19.32, Carson <E.Carson...@gmail.com> wrote:
>
> @products = Product.find(:all, :conditions => "on_catalog_promotion =
> true" )
>
Try these:
:conditions => {:on_catalog_promotion => true}
Or
:conditions => "on_catalog_promotion is true"
//jarkko
> Well, appearantly, the :conditions option only accepts boolean
> comparison to "1" or "0" -- not "true" or "false". I changed and
> reloaded the fixture and it worked fine.
>
> Thanks, sometimes the answer only comes to me after I've asked for
> help.
:conditions the way you used it just passes the string straight to SQL
so it's a matter of whether the SQL engine you use accepts it. In that
sense it's always safer to use the hash form when your conditions are
simple enough for it, or the array form:
:conditions => ["on_catalog_promotion = ?", true]
Using those, the db adapter will take care of using correct options in
the SQL statement. In your case, I would prefer the hash form because
it looks the cleanest and doesn't require any use of strings. Note
that this is also exactly the same as
Product.find_all_by_on_catalog_promotion(true), which might win the
beauty contest in someone's book.
//jarkko
>
> Carson
>
> On Wed, Apr 23, 2008 at 12:36 PM, Jarkko Laine <jar...@jlaine.net>
> wrote:
>
>
>
> On 23.4.2008, at 19.32, Carson <E.Carson...@gmail.com> wrote:
>
> >
> > @products = Product.find(:all, :conditions =>
> "on_catalog_promotion =
> > true" )
> >
>
> Try these:
>
> :conditions => {:on_catalog_promotion => true}
>
> Or
>
> :conditions => "on_catalog_promotion is true"
>
> //jarkko
>
> > produces this error message:
> >
> > SQLite3::SQLException: no such column: true: SELECT * FROM products
> > WHERE (on_catalog_promotion = true)
> >
> > The Products table has such a column and it is filled with true or
> > false for each product.
> >
> > Any ideas? I'm puzzled.
> >
> > Carson
> > >
>
>
>
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "Beginning Ruby on Rails E-Commerce" group.
> To post to this group, send email to railsec...@googlegroups.com
> To unsubscribe from this group, send email to railsecommerc...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/railsecommerce?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi
> Well, Jarkko, I always learn something when I receive a reply from
> you. Thanks.
>
> I have a nagging question from when I worked through your e-comm
> project a couple of months ago. Your db:migration for Carts has no
> fields listed (one is there, but it is commented out). That means
> that it only records a system generated id, correct? Is that its
> only purpose?
In that phase of the system, yes, since there's no user authentication
or anything for customers.
//jarkko
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "Beginning Ruby on Rails E-Commerce" group.
> To post to this group, send email to railsec...@googlegroups.com
> To unsubscribe from this group, send email to railsecommerc...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/railsecommerce?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
--