via: http://blog.pivotal.io/labs/labs/leave-your-migrations-in-your-rails-engines
in lib/[engine_name]/engine.rb
initializer :append_migrations do |app|
unless app.root.to_s.match root.to_s
config.paths["db/migrate"].expanded.each do |expanded_path|
app.config.paths["db/migrate"] << expanded_path
end
end
end
in lib/[engine_name]/engine.rb
root = File.expand_path('../../', __FILE__)
config.autoload_paths << root
config.to_prepare do
Dir[File.join(root, "../app/decorators/**/*_decorator*.rb")].each do |c|
require_dependency(c)
end
end
in spec/rails_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
- http://guides.rubyonrails.org/engines.html
- http://guides.rubyonrails.org/generators.html
- http://tech.taskrabbit.com/blog/2014/02/11/rails-4-engines/
- http://www.toptal.com/ruby-on-rails/rails-engines-in-the-wild-real-world-examples-of-rails-engines-in-action
- http://brandonhilkert.com/blog/how-to-build-a-rails-engine/
- https://teamgaslight.com/blog/maintainable-and-scalable-systems-with-rails-engines
- http://asciicasts.com/episodes/277-mountable-engines