Skip to content

Instantly share code, notes, and snippets.

@garethrees
Created June 23, 2017 12:29
Show Gist options
  • Select an option

  • Save garethrees/c6f51d58280b7c9e13707c075e0696c7 to your computer and use it in GitHub Desktop.

Select an option

Save garethrees/c6f51d58280b7c9e13707c075e0696c7 to your computer and use it in GitHub Desktop.
has_and_belongs_to_many :assemblies, -> {
order(:name)
}
# ActiveRecord::StatementInvalid: SQLite3::SQLException:
# no such column: assemblies.name:
# SELECT "assemblies".*
# FROM "assemblies"
# INNER JOIN "assemblies_parts"
# ON "assemblies"."id" = "assemblies_parts"."assembly_id"
# WHERE "assemblies_parts"."part_id" = ?
# ORDER BY "assemblies"."name" ASC
# ^^ Note the ORDER BY value ^^
has_and_belongs_to_many :assemblies, -> {
order(:name)
}
# ActiveRecord::StatementInvalid: SQLite3::SQLException:
# no such column: assembly_translations.name:
# SELECT "assemblies".*
# FROM "assemblies"
# INNER JOIN "assemblies_parts"
# ON "assemblies"."id" = "assemblies_parts"."assembly_id"
# WHERE "assemblies_parts"."part_id" = ?
# ORDER BY assembly_translations.name
# ^^ Note the ORDER BY value ^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment