Skip to content

Instantly share code, notes, and snippets.

@myabc
Created March 14, 2009 13:06
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 myabc/79061 to your computer and use it in GitHub Desktop.
Save myabc/79061 to your computer and use it in GitHub Desktop.
diff --git a/config/router.rb b/config/router.rb
index e128a6a..23b9686 100644
--- a/config/router.rb
+++ b/config/router.rb
@@ -32,14 +32,23 @@ Merb::Router.prepare do
# Adds the required routes for merb-auth using the password slice
slice(:merb_auth_slice_password, :name_prefix => nil, :path_prefix => "", :path => "blog/admin")
-
+
+ # WORKAROUND: Deferred routes don't appear to be working correctly from the
+ # slice itself.
+ # This deferred route allows permalinks to be handled, without a separate rack handler
+ match(/\/blog\/.*/).defer_to do |request, params|
+ unless (id = Feather::Article.routing[request.uri.to_s.chomp("/").gsub(/\/blog/,'')]).nil?
+ {:controller => "feather/articles", :action => "show", :id => id}
+ end
+ end
+
slice(:feather, :name_prefix => nil, :path_prefix => nil, :path => "blog")
-
+
# This is the default route for /:controller/:action/:id
# This is fine for most cases. If you're heavily using resource-based
# routes, you may want to comment/remove this line to prevent
# clients from calling your create or destroy actions with a GET
- default_routes
+ # default_routes
# Change this for your home page to be available at /
match('/').to(:controller => 'home', :action =>'index')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment