3

我正在尝试使用类似于的调用来销毁对象

MyObject.destroy_all({:user_id => current_user.id, :item_type_id => params[:type_id], :item_id => params[:item_id]})

Rails 将其生成为 SQL 命令:

User Load (0.5ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
MyObject Load (0.2ms)  SELECT `my_objects`.* FROM `my_objects` WHERE `my_objects`.`user_id` = 1 AND `my_objects`.`item_type_id` = 3 AND `my_objects`.`item_id` = 9
(0.1ms)  BEGIN 
SQL (0.4ms)  DELETE FROM `my_objects` WHERE `my_objects`.`` = NULL

最后一条 SQL 语句导致此错误(这是有道理的)

Mysql2::Error: Unknown column 'my_objects.' in 'where clause': DELETE FROM `my_objects` WHERE `my_objects`.`` = NULL

难道我做错了什么?

Rails 3.2.1 mysql2 0.3.11 mysql 5(我认为)

4

0 回答 0