Created
February 10, 2009 15:27
-
-
Save maiha/61428 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################ | |
### Problem | |
############################################################ | |
Merb::Router.compiled_statement generates invalid ruby codes | |
############################################################ | |
### Detail | |
############################################################ | |
% merb -i | |
Loading /Users/maiha/ruby19/test/config/environments/development.rb | |
[" ~ Connecting to database...\n"][" ~ Parent pid: 44727\n"][" ~ Compiling routes...\n"][" ~ Skipped add | |
ing slice merb_auth_slice_password to router...\n"] | |
Generated code failed: def match(request) | |
cached_path = request.path.to_s | |
if (/^\/([^\/.,;?]+)(?:\/([^\/.,;?]+)(?:\/([^\/.,;?]+))?)?(?:\.([^\/.,;?]+))?$/ =~ cached_path && ((p | |
ath1, path2, path3, path4 = $1, $2, $3, $4) || true)) | |
[0, {:controller => (path1), :action => (path2 || "index"), :id => (path3), :format => (path4)}] | |
else | |
[nil, {}] | |
end | |
end | |
[" ~ Cannot load /Users/maiha/ruby19/test/config/router.rb because of syntax error: Generated Code for Router:7: multiple assignment in conditional\n"]irb: warn: can't alias context from irb_context. | |
############################################################ | |
### Goal | |
############################################################ | |
It should be like this. | |
def match(request) | |
cached_path = request.path.to_s | |
if (/^\/([^\/.,;?]+)(?:\/([^\/.,;?]+)(?:\/([^\/.,;?]+))?)?(?:\.([^\/.,;?]+))?$/ =~ cached_path | |
path1, path2, path3, path4 = $1, $2, $3, $4 | |
[0, {:controller => (path1), :action => (path2 || "index"), :id => (path3), :format => (path4)}] | |
else | |
[nil, {}] | |
end | |
end | |
############################################################ | |
### Status | |
############################################################ | |
Gave up | |
merb-core/lib/merb-core/dispatch/router/route.rb is heavy to me |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment