ruby on rails - How can I check multiple value in Model enum -


i want check status of instance if has more 2 values

this model use rails enum

class product < activerecord::base   enum status: [:status1, :status2, :status3] end 

i can check 1 status of instance use rails enum like

product.first.status1? 

if want check multiple statuses this

product.first.status1? || product.first.status2? 

how can check enum values like

product.first.status?(:status1, :status2)`# not work 

does method exist?

simple answer :

[:status1, :status2].include?(product.first.status) 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -