16. THE ENGINE
module Cowboy
class Engine < ::Rails::Engine
isolate_namespace
config.autoload_paths += [File.join( self.root, %w[lib blee] )]
end
end
Tuesday, September 17, 13
17. BUSINESS AS USUAL
rails g [model|controller|migration]
custom generators
engine initializers
Tuesday, September 17, 13
23. MONKEYMIGS!
module Cowboy
class Engine < ::Rails::Engine
isolate_namespace Cowboy
initializer :append_migrations do |app|
next if app.root.to_s.match self.root.to_s
config.paths["db/migrate"].expanded.each do |expanded_path|
app.config.paths["db/migrate"] << expanded_path
end
end
end
end
Tuesday, September 17, 13
24. ISOLATED MODELS
table names expects engine_name_table_name
self.table_name = :guns
or
table_name_prefix = “”
Tuesday, September 17, 13
27. APP ROUTES
Rango::Application.routes.draw do
root 'welcome#index'
mount Cowboy::Engine => '/pilgrim', as: :cowboy_ng
resources :jenkins do
resources :bullets, controller: 'cowboy/bullets'
end
end
rango/config/routes.rb
Tuesday, September 17, 13
36. LAB II
Scenario: Other models in the system need to be
commentable. Spin out this functionality as a new
‘social’ engine
Tuesday, September 17, 13
37. CHEAT
> rails plugin new engines/social -T --mountable
-j coffeescript -B -d mysql
--dummy-path=spec/dummy
Tuesday, September 17, 13
38. LAB III
Scenario: PM wants a reporting admin ui to track
comments. In light of this new feature commenting
behavior needs to be shared across several engines.
Refactor social engine to depend on the new
common engine
Tuesday, September 17, 13