Home > Software design >  What rails console command can be used to query all the users whom has a home_state value in a table
What rails console command can be used to query all the users whom has a home_state value in a table

Time:01-27

I need a rails command that can query all the users who has a value in home_state. I have tried to use:

User.where('home_state')

but couldn't retrieve any information from it.

CodePudding user response:

If you are looking for all users that do not have nil as a value for home_state, you can use User.where.not(home_state: nil)

CodePudding user response:

You can use User.where.not(home_state: nil)

  •  Tags:  
  • Related