Hello-
I’m trying to get a list of attachment_fu objects (type of
ProductImage) to play well with acts_as_list. Essentially, a single
Product can have multiple ProductImages arranged in a sorted list
(which feeds into a slideshow, ultimately).
If it wasn’t clear from the title, this isn’t going well. The problem
is in how attachment_fu adds multiple records to the database (one for
the main image and one for each thumbnail). I’ve been trying various
scoping options to get this to work, but to no avail. Here is my
latest try, which I had high expectations for:
acts_as_list :scope => ‘product_id = #{product_id} and parent_id is
null’
The error I get back is this:
Mysql::Error: You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to
use near ‘and parent_id is null) ORDER BY position DESC LIMIT 1’ at
line 1: SELECT * FROM product_images
WHERE (product_id = and
parent_id is null) ORDER BY position DESC LIMIT 1
So, somewhere along the road I’m trying to retrieve things from the
database, but passing in a null product_id.
Does anyone know how to bring attachment_fu and acts_as_list together
as friends?
Thanks in advance.
-Eric