Rails where condition using NOT NIL

Rails 4+ ActiveRecord 4.0 and above adds where.not so you can do this: Foo.includes(:bar).where.not(‘bars.id’ => nil) Foo.includes(:bar).where.not(bars: { id: nil }) When working with scopes between tables, I prefer to leverage merge so that I can use existing scopes more easily. Foo.includes(:bar).merge(Bar.where.not(id: nil)) Also, since includes does not always choose a join strategy, you should … Read more

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