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

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -