0
我得到一個奇怪的錯誤:的Rails 3 ActiveRecord的遷移 - 的ActiveRecord :: StatementInvalid
ActiveRecord::StatementInvalid in AdminController#edit_user
NoMethodError: undefined method `empty?' for 663:Fixnum: SELECT privileges.*, ...
In: app/controllers/admin_controller.rb:75:in `edit_user'
這裏是有問題的行:
#line #75 from admin_controller.rb
@privileges = Privilege.find_by_sql("SELECT privileges.*, vendors.name AS vendor_name FROM privileges LEFT JOIN vendors ON vendors.id = rivileges.vendor_id WHERE user_id = ? ORDER BY vendors.name", @user.id)
我可以通過取出修復佔位符,但我不想這樣做:
@privileges = Privilege.find_by_sql("SELECT privileges.*, vendors.name AS vendor_name FROM privileges LEFT JOIN vendors ON vendors.id = privileges.vendor_id WHERE b2b_user_id = "[email protected]_s+" ORDER BY vendors.name")
fin在Rails 3中,d_by_sql尚未被棄用,我可以將該查詢抽入數據庫。
我覺得奇怪的是,沒有電話「空」嗎?在我的admin_controller。這是一個內部調用通過Rails清空?
請指教。
謝謝
在第一個查詢,你提到它作爲rivileges.vendor_id WHERE。這是一個錯字嗎? – felix 2013-03-26 13:26:09