Created
October 21, 2015 20:08
-
-
Save christopherstyles/811e0e8b053aa591779b to your computer and use it in GitHub Desktop.
Requiring STI dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module YourNamespace | |
| class Item < ActiveRecord::Base | |
| end | |
| end | |
| YourNamespace.require_sti_dependencies(:item) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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