这些 AREL 查询在 Rails 3 中不起作用。有人可以帮我破译这个错误吗?
NoMethodError (undefined method `id' for #<ActiveRecord::Relation:0xabf6f44>):
app/controllers/admin_controller.rb:206:in `save_user'
所有这些都会导致与上图相同的错误
@existing = Privilege.find(:first, :conditions => "b2b_user_id = #{@user.id} AND vendor_id = #{@vendor_id}")
@existing = Privilege.find_by_sql("SELECT * FROM b2b_privileges WHERE b2b_user_id = ? AND vendor_id = ? LIMIT 1",@user.id,@vendor_id)
@existing = Privilege.where(:b2b_user_id => @user.id, :vendor_id => @vendor_id)
但是当我改变这个时:
@user = B2bUser.where("id = ?",params[:id])
对此:
@user = B2bUser.find_by_id(params[:id])
查询有效。为什么?
谢谢