Skip to content

Instantly share code, notes, and snippets.

@garethrees
Created June 23, 2017 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garethrees/aef31364b1bf7619170aa79c2d6b99dc to your computer and use it in GitHub Desktop.
Save garethrees/aef31364b1bf7619170aa79c2d6b99dc to your computer and use it in GitHub Desktop.
# app/models/assembly.rb
class Assembly < ActiveRecord::Base
has_and_belongs_to_many :parts
translates :name
end
# app/models/part.rb
class Part < ActiveRecord::Base
has_and_belongs_to_many :assemblies, -> {
order('assembly_translations.name asc')
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment