Using a scope from a related model in another scope

Try this:

scope :engine_parts, lambda { joins(:part_category).merge(PartCategory.engine) } 

Basically, the result of joins(:part_category) is the join of two models, so you can’t call .engine on it directly, you need to compose scopes in this manner.

See Here for more

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)