Module: ActiveItem::ModelLoader
- Included in:
- Associations, Relation
- Defined in:
- lib/active_item/model_loader.rb
Instance Method Summary collapse
Instance Method Details
#safe_constantize_model(class_name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/active_item/model_loader.rb', line 7 def safe_constantize_model(class_name) return class_name.constantize if Object.const_defined?(class_name) file_name = class_name.underscore # Try common model paths ['.', 'models', 'app/models'].each do |dir| path = File.join(dir, "#{file_name}.rb") if File.exist?(path) require path break end end class_name.constantize end |