I want to run a query on my User model, like this:
@user = User.find(:all, :conditions=>["u_org != c_org and u_org == ?", current_web.role.id])
This is the older style for running queries and it is not working as well. Can you please help me to run it in rails 3. I have tried:
@user = User.where("u_org != c_org and u_org == ?", current_web.role.id).all
and the result was [].
Update:
I have removed == as per the answer and still the query returns []. I have tried only with @user = User.find(:all, :conditions=>["u_org = ?", current_web.role.id]) and the value is returned successfully but i want it to be @user = User.find(:all, :conditions=>["u_org != c_org and u_org = ?", current_web.role.id])
Edit:
Sample Data:
u_org = 1
c_org = null
current_web.role.id = 1