Skip to content

@mrbrdo /gist:6987484
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
# AR & Sequel
User.where(name: "Tom")
User.where("name = :name", name: "Tom")
User.where("name = ? OR email = ?", "Tom", "jack@jack.com")
User.where("users.name = ?", "Tom")
# AR-only
User.where(users: { name: "Tom" })
# Sequel-only
User.where(users__name: "Tom")
User.where(Sequel.lit('users.name') => "Tom")
# Sequel alternative option for "name = ? OR email = ?"
User.where(Sequel.expr(name: "Tom") | Sequel.expr(email: "jack@jack.com"))
# Sequel alternative option for "name = ? OR email != ?"
User.where(Sequel.expr(name: "Tom") | Sequel.~(email: "jack@jack.com"))
# AR-only
User.select("SUM(id)").first
# Sequel-only
User.select(Sequel.function(:sum, :id)).first
User.select(Sequel.lit("SUM(id)")).first
# AR-only (4.x)
User.where.not(name: "Tom")
# Sequel-only
User.exclude(name: "Tom")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.