Ruby on rails find an associated objects which has another association too -


i have 3 models, organized way:

class task < ar::base   has_one :taskable  class taskable   belongs_to :task   has_many :supplies  class supply < ar::base   belongs_to :taskable 

how can fetch tasks, taskable has @ least 1 supply?

you need join query .

# fetch tasks, taskable has @ least 1 supply task.joins(taskable: :supplies) 

Comments

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

How to connect android app to App engine -

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -