Is there a better way to write this
I have A Condition which previous Look Very clean and easy to understand
like
Account.first.websites.last.users.find(:all,
:conditions => {:country => "XYZ",:status => "Single",:admin => nil)
Now the big problem is that user with admin = false is not picked up.
i.e I want all the users from a specific country, having status as
“Single” and admin is either “nil” (Null in database) or “false”.
I manage to get desired code but doesn’t seem to be happy with clarity
of it.
Account.first.websites.last.users.find(:all,
:conditions => ["country = ? AND status = ? AND admin IS NULL OR
admin = ?","XYZ","Single","false"])
Any help would be appreciated.
thanks
I would add some scopes to model:
then use it in controllers:
You can also use autogenerated scopes:
Here I left only
not_adminscope.