jasonmk / datastax_rails

A Ruby-on-Rails interface to Datastax Enterprise. Replaces the majority of ActiveRecord functionality.
MIT License
23 stars 9 forks source link

Use Rails configuration paths in migrator #23

Closed davidkelley closed 10 years ago

davidkelley commented 10 years ago

This change affects how files are loaded in during the migration. Using Rails.configuration.paths instead of joining with Rails.root allows Rails Engines to patch in their own models to be included inside the migration.

This enables something like the following:

class Engine < ::Rails::Engine
  initializer :append_models do |app|
      paths.add(engine_models = "app/models/#{self.engine_name}")
      config.paths[engine_models].expanded.each do |expanded_path|
        app.config.paths['app/models'] << expanded_path
      end
    end
end

Otherwise every model that an engine defines, would need to be extended by the application as a separate model to be found by the migrator.

jasonmk commented 10 years ago

Thanks for the commit. I haven't done much with engines, but this definitely makes sense. I was never thrilled with the way I was doing it. I'll push this out next time I push a new version.

Cheers, Jason

davidkelley commented 10 years ago

No problem. I'm in the middle of implementing your gem into a Rails Engine; happy to contribute back :+1: