Create a gist now

Instantly share code, notes, and snippets.

# my_engine/lib/engine.rb
require "my_engine"
require "rails"
module MyEngine
class Engine < Rails::Engine
end
module Routes
def self.draw(map)
map.instance_exec do
match "/my_engine", :to => "my_engine#foo"
end
end
end
end
# my_app/config/routes.rb
MyApp::Application.routes.draw do
MyEngine::Routes.draw(self)
end
# $ rake routes
my_engine /my_engine {:controller=>"my_engine", :action=>"foo"}
# my_engine/lib/engine.rb
require "my_engine"
require "rails"
module MyEngine
class Engine < Rails::Engine
end
module Routes
def self.draw(map)
map.instance_exec do
match "/my_engine", :to => "my_engine#foo"
end
end
end
end
# my_app/config/routes.rb
MyApp::Application.routes.draw do
scope "bar" do
MyEngine::Routes.draw(self)
end
end
# $ rake routes
bar_my_engine /bar/my_engine {:controller=>"my_engine", :action=>"foo"}
# my_engine/lib/engine.rb
require "my_engine"
require "rails"
module MyEngine
class Engine < Rails::Engine
end
module Routes
def self.draw(map)
map.instance_exec do
scope "baz" do
match "/my_engine", :to => "my_engine#foo"
end
end
end
end
end
# my_app/config/routes.rb
MyApp::Application.routes.draw do
scope "bar" do
MyEngine::Routes.draw(self)
end
end
# $ rake routes
bar_baz_my_engine /bar/baz/my_engine {:controller=>"my_engine", :action=>"foo"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment