Skip to content

Instantly share code, notes, and snippets.

View pixeltrix's full-sized avatar

Andrew White pixeltrix

View GitHub Profile
From 7ab3de7ad7765b31a24f366bf2338128a3912b24 Mon Sep 17 00:00:00 2001
From: Andrew White <andyw@pixeltrix.co.uk>
Date: Sun, 4 Jul 2010 06:52:52 +0100
Subject: [PATCH] Refactor resource options and scoping. Resource classes are now
only responsible for controlling how they are named. All other
options passed to resources are pushed out to the scope.
---
actionpack/lib/action_dispatch/routing/mapper.rb | 163 +++++++++-------------
actionpack/test/dispatch/routing_test.rb | 83 +++++++++++-
From c8cff4fe661791548f266671a06b36c24ca9e94b Mon Sep 17 00:00:00 2001
From: Andrew White <andyw@pixeltrix.co.uk>
Date: Sun, 4 Jul 2010 17:35:34 +0100
Subject: [PATCH] Fix syntax of routing tests so they actually run
---
actionpack/test/dispatch/routing_test.rb | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
From 6fd41cca5c4189e7937307b707574e82802b4dea Mon Sep 17 00:00:00 2001
From: Andrew White <andyw@pixeltrix.co.uk>
Date: Tue, 6 Jul 2010 15:32:47 +0100
Subject: [PATCH] Move path prefix to controller requirement so that
recognition and generation of namespaced default routes work
[#5052 state:resolved]
---
actionpack/lib/action_dispatch/routing/mapper.rb | 15 +++++++++++++--
.../lib/action_dispatch/routing/route_set.rb | 6 ++----
From 8b47af9fc6f29b552caff5484a33f7325b061d9e Mon Sep 17 00:00:00 2001
From: Andrew White <andyw@pixeltrix.co.uk>
Date: Tue, 6 Jul 2010 19:06:02 +0100
Subject: [PATCH] Refactor handling of :only and :except options. The rules are:
1. Don't inherit when specified as an option on a resource
2. Don't push into scope when specified as an option on a resource
2. Resources pull in :only or :except options from scope
3. Either :only or :except in nested scope overwrites parent scope
From 210b89938aea9bd514379f2a509049f173c1a56f Mon Sep 17 00:00:00 2001
From: Andrew White <andyw@pixeltrix.co.uk>
Date: Tue, 6 Jul 2010 22:20:06 +0100
Subject: [PATCH] When a dynamic :controller segment is present in the path add a
Regexp constraint that allow matching on multiple path segments.
Using a namespace block isn't compatible with dynamic routes so we
raise an ArgumentError if we detect a :module present in the scope.
[#5052 state:resolved]
# Manage cross engine/plugin dependencies by deferring resolution
# until all plugins have been loaded and then including them after
# the main class definition has been loaded.
# lib/mercium.rb
module Mercium
mattr_reader :extensions
@@extensions = {}
def self.register_extension(klass, extension)
From d00ce654a1442dcea7bf9585647d1b7015cc9cbe Mon Sep 17 00:00:00 2001
From: Andrew White <andyw@pixeltrix.co.uk>
Date: Tue, 24 Aug 2010 22:16:34 +0100
Subject: [PATCH] Use nested scope for routes defined at the :resources scope level
---
actionpack/lib/action_dispatch/routing/mapper.rb | 11 ++++++-----
actionpack/test/dispatch/routing_test.rb | 7 +++++++
2 files changed, 13 insertions(+), 5 deletions(-)
From ac01dfb12e217928ac5f2b53e093b202d842af4f Mon Sep 17 00:00:00 2001
From: Andrew White <andyw@pixeltrix.co.uk>
Date: Sat, 28 Aug 2010 00:28:46 +0100
Subject: [PATCH] Read the route name directly from the route instead of looking it up in the named routes hash
---
railties/lib/rails/tasks/routes.rake | 8 +-------
1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake
From 45980ca687c7e858eaf5f70d1869645aca2ac755 Mon Sep 17 00:00:00 2001
From: Andrew White <andyw@pixeltrix.co.uk>
Date: Tue, 31 Aug 2010 17:02:49 +0100
Subject: [PATCH] Move implicit nested call before options handling so that nested constraints work
---
actionpack/lib/action_dispatch/routing/mapper.rb | 16 +++++++---------
actionpack/test/dispatch/routing_test.rb | 18 ++++++++++++++++++
2 files changed, 25 insertions(+), 9 deletions(-)
@pixeltrix
pixeltrix / routes.rb
Created October 29, 2010 13:21
Examples of advanced Rails 3.0 routes
Rails.application.routes.draw do
get '/(:locale)/products/(:category)/(page/:page).:extension',
:to => 'products#index',
:as => :products,
:constraints => {
:locale => /[a-z]{2}/,
:category => /.+?/,
:page => /\d+/
},