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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

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

c# - Search and Add Comment with OpenXML for Word -