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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -