Skip to content

Instantly share code, notes, and snippets.

@christopherstyles
Created October 21, 2015 20:08
Show Gist options
  • Select an option

  • Save christopherstyles/811e0e8b053aa591779b to your computer and use it in GitHub Desktop.

Select an option

Save christopherstyles/811e0e8b053aa591779b to your computer and use it in GitHub Desktop.
Requiring STI dependencies
module YourNamespace
class Item < ActiveRecord::Base
end
end
YourNamespace.require_sti_dependencies(:item)
module YourNamespace
def self.require_sti_dependencies(model)
# Preload STI classes in development
# See: https://github.com/rails/rails/issues/8699
Dir["#{Rails.root}/app/models/clubs/#{model.to_s}/*.rb"].each do |file|
require_dependency file
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment