Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Rails configuration paths in migrator #23

Merged
merged 3 commits into from
May 22, 2014

Conversation

davidkelley
Copy link
Contributor

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 jasonmk merged commit 5e66137 into jasonmk:master May 22, 2014
@jasonmk
Copy link
Owner

jasonmk commented May 22, 2014

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants