Answers for "rails Arel::Table"

0

arel_table rails

Address.where( Address.arel_table[:created_at].lt( 5.days.ago ) ).to_sql
# SELECT "addresses".* FROM "addresses"  WHERE ("addresses"."created_at" < '2016-12-13 03:31:23.911914')
Posted by: Guest on October-13-2020
0

arel_table rails

veg = Arel::Table.new(:vegetables)
query = veg[:created_at].gteq( 5.days.ago ).and(
  veg[:color].eq("green").or(
    veg[:gardener].eq("Susan")
  )
)
query.to_sql
#  "vegetables"."created_at" >= '2016-12-13 03:54:28.575342'
#    AND ("vegetables"."color" = 'green' OR "vegetables"."gardener" = 'Susan')
Vegetable.where( query )
Posted by: Guest on October-13-2020

Browse Popular Code Answers by Language