I have a user table in that department_id is one of the field and i have to check two condition where :department_id=>current_user.id or department_id=> null.
I do not know how to write query for this in rails3.
I have a user table in that department_id is one of the field and i have to check two condition where :department_id=>current_user.id or department_id=> null.
I do not know how to write query for this in rails3.
Here is an example assuming you have a Customer model.
Customer.where("department_id = ? OR department_id IS NULL", current_user.id)
You may also check the guides here:
http://guides.rubyonrails.org/active_record_querying.html#conditions