Home Rails scope where account has user
Reply: 0

Rails scope where account has user

user385 Published in March 19, 2018, 12:54 am

I have an account and a user model where an account has_one user. So in my user table I have the account_id.

I want to create a scope for my accounts where I can pass has_user = TUE/FALSE and it returns the accounts with/without user.

scope :has_user, -> (has_user) { where(...) }

Can anybody help how to write this scope?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309969 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO