Skip to content

Instantly share code, notes, and snippets.

@david
Created November 15, 2012 18:38
Show Gist options
  • Save david/4080359 to your computer and use it in GitHub Desktop.
Save david/4080359 to your computer and use it in GitHub Desktop.
Which is better?
# admin/real_estate_companies.rb
ActiveAdmin.register RealEstateCompany do
form do |f|
f.inputs do
f.input :vendors, collection: Vendor.sorted_by_name
end
end
end
# models/vendor.rb
class Vendor
scope :sorted_by_name, order(:name)
end
# admin/real_estate_companies.rb
ActiveAdmin.register RealEstateCompany do
form do |f|
f.inputs do
f.input :vendors, collection: Vendor.sorted_for_real_estate_companies_admin
end
end
end
# models/vendor.rb
class Vendor
scope :sorted_for_real_estate_companies_admin, order(:name)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment