Skip to content

Instantly share code, notes, and snippets.

@ordinz
Created April 11, 2011 22:02
Show Gist options
  • Save ordinz/914469 to your computer and use it in GitHub Desktop.
Save ordinz/914469 to your computer and use it in GitHub Desktop.
convert rails 2 routes to rails 3
controller = 'reports'
str = %{
map.reports '/reports', :action => 'index'
map.reports_by_month '/reports/by_month', :action => 'by_month'
map.report_for_client '/reports/client/:id', :action => 'client'
}
scans=str.scan(/[a-z]+\.(\S+)\s+(\'.*\'),\s+:action\s+=>\s+'(.*)'/)
matches = scans.collect {|scan| "match #{scan[1]} => '#{controller}##{scan[2]}', :as => '#{scan[0]}'"}; nil
matches.each {|m| puts m }; nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment