Skip to content

Instantly share code, notes, and snippets.

@christopherhein
Created October 9, 2012 08:02
Show Gist options
  • Select an option

  • Save christopherhein/3857274 to your computer and use it in GitHub Desktop.

Select an option

Save christopherhein/3857274 to your computer and use it in GitHub Desktop.
decided to make some changes to allow for a single method to autoload external routing files
# I've been meaning to send this too you... Remember the #draw method you pulled out of edge rails, well after using it in a personal
# project (which by the way is awesome, totally digging it) I decided that I wanted to include more files in the one method, to reduce
# the amount of times I wrote draw :something, so I modified it a little and thought you'd appreciate it... Cheers!
# In lib/mapper.rb
module ActionDispatch
module Routing
module Mapper
def draw *route_names
route_names.each do |route_name|
instance_eval File.read(Rails.root.join("config/routes/#{route_name}.rb"))
end
end
end
end
end
# in routes.rb
Rails::Application.routes.draw do
draw :api, :admin, :application
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment