View Review Details


Book:   Ruby on Rails: Up and Running
Subject:   drag & drop example not working for me?
Date:   2007-10-10 15:08:28
From:   Anonymous Reader
Rating:  StarStarStarStarStar

I like this book because it is short, thin, and to the point. It gives me just enough information to get started. The examples worked fine until I tried the drag & drop one.


This is probably not the place to ask a question like this. But, please let me...


The error from drag & drop operation:


Processing SlideshowsController#add_photo (for 10.71.1.169 at 2007-10-10 14:44:43) [POST]
Session ID: 253902577ac03cf8a5c6393c3721dade
Parameters: {"action"=>"add_photo", "id"=>"photo_3", "controller"=>"slideshows"}
SQL (0.002208)  SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = 'slides'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

SQL (0.000436) BEGIN
Slide Load (0.000000) RuntimeError: ERROR C42804 Margument of WHERE must be type boolean, not type integer Fparse_coerce.c L818 Rcoerce_to_boolean: SELECT * FROM slides WHERE (slideshow_id) ORDER BY position DESC LIMIT 1
SQL (0.000429) ROLLBACK


ActiveRecord::StatementInvalid (RuntimeError: ERROR C42804 Margument of WHERE must be type boolean, not type integer Fparse_coerce.c L818 Rcoerce_to_boolean: SELECT * FROM slides WHERE (slideshow_id) ORDER BY position DESC LIMIT 1):
........


Based on the above error, the problem seems to be with the generated select statement.


SELECT * FROM slides WHERE (slideshow_id) ORDER BY position DESC LIMIT 1)


Instead, it should be:


SELECT * FROM slides WHERE (slideshow_id = 3) ORDER BY position DESC LIMIT 1)


I also tried the following:


>> slide = Slide.find 1
>> slideshow = slide.slideshow
>> slideshow.slides.first.move_to_bottom
ActiveRecord::StatementInvalid: RuntimeError: ERROR C42804 Margument of AND must be type boolean, not type integer Fparse_coerce.c L818 Rcoerce_to_boolean: UPDATE slides SET position = (position - 1) WHERE (slideshow_id AND position > 1)


Same kind of problem. The update statement should be like:


UPDATE slides SET position = (position - 1) WHERE (slideshow_id = 3 AND position > 1)


I am not sure how to correct this problem. Please help.


See larger cover

"If you've learned Ruby and you're ready to take the next step to Rails, this is definitely a decent choice for a quick immersion without wading through 900 pages of technical reference."
--Thomas "Duffbert" Duff, Duffbert's Random Musings