次のように、 User モデルでクエリを実行したいと思います。
@user = User.find(:all, :conditions=>["u_org != c_org and u_org == ?", current_web.role.id])
これはクエリを実行するための古いスタイルであり、同様に機能していません。Rails 3で実行するのを手伝ってくれませんか。私は試しました:
@user = User.where("u_org != c_org and u_org == ?", current_web.role.id).all
結果は[]でした。
アップデート:
==
回答に従って削除しましたが、それでもクエリは を返します[]
。私はでのみ試してみ@user = User.find(:all, :conditions=>["u_org = ?", current_web.role.id])
ましたが、値は正常に返されましたが、それをしたいです@user = User.find(:all, :conditions=>["u_org != c_org and u_org = ?", current_web.role.id])
編集:
サンプルデータ:
u_org = 1
c_org = null
current_web.role.id = 1