Skip to content

Instantly share code, notes, and snippets.

@teamon
Created August 3, 2010 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teamon/506390 to your computer and use it in GitHub Desktop.
Save teamon/506390 to your computer and use it in GitHub Desktop.
# 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