|
List Info
Thread: bug in routes ???
|
|
| bug in routes ??? |

|
2006-09-21 09:39:53 |
|
[I had posted to the normal talk mailing list but subsequently thought it perhaps should have been posted here?]
Hi,
Is this a bug in routes.rb, or something I'm doing wrong. Basically from what I can tell the
url_for being generated in the case where my existing controller had a
forward slash (i.e.
active_rbac/login) may be causing a problem. I'm creating a link to a
different controller however the URL created has a piece of the
previous controller in it (i.e. active_rbac/). I put a breakpoint in
the view and the run the following to confirm, see below. Also note
the login aspects use a plugin.
Is this a bug?
============== debug / irb ========================= irb(#<#<Class:0x39bea80>:0x39bea50>):051:0* params => {"action"=>"login", "controller"=>"active_rbac/login", "locale"=>"en"}
irb(#<#<Class:0x39bea80>:0x39bea50>):052:0> session[:locale] => "en"
irb(#<#<Class:0x39bea80>:0x39bea50>):053:0> url_for => "/en/active_rbac/login/login"
irb(#<#<Class:0x39bea80>:0x39bea50>):054:0> url_for :locale => "fr" => "/fr/active_rbac/login"
irb(#<#<Class:0x39bea80>:0x39bea50>):055:0> url_for :locale => "fr", :controller => "splash"
=> "/fr/active_rbac/splash" <== PROBLEM HERE, I expect to see "/fr/splash"
irb(#<#<Class:0x39bea80>:0x39bea50>):056:0>
==================== ActionController::Routing::Routes.draw do |map|
map.connect '/admin/group/:action/:id', :controller => 'active_rbac/group'
map.connect '/admin/role/:action/:id', :controller => 'active_rbac/role' map.connect '/admin/static_permission/:action/:id', :controller => 'active_rbac/static_permission' map.connect '/admin/user/:action/:id', :controller => 'active_rbac/user'
map.connect '/login/:en', :controller => 'active_rbac/login', :action => 'login' map.connect '/logout', :controller => 'active_rbac/login',:action => 'logout'
map.connect '/register/confirm/:user/:token', :controller => 'active_rbac/registration', :action => 'confirm' map.connect '/register/:action/:id', :controller => 'active_rbac/registration'
map.splash ':locale', :controller => 'splash', :locale => nil, :defaults => { :locale => "en" } map.connect ':locale/:controller/:action/:id',
:defaults => { :locale => "en", :controller => "splash" }
end ====================
Thanks Greg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core -~----------~----~----~----~------~----~------~--~---
|
| bug in routes ??? |

|
2006-09-21 12:09:04 |
2006/9/21, Greg Hauptmann <greg.hauptmann.ruby gmail.com>:
> Is this a bug?
You gave url_for a relative path, so it does what is
expected: a
relative path construction. What happens if you use an
absolute path
?
Bye !
--
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.
org/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe googlegroups.com
For more options, visit this group at http:
//groups.google.com/group/rubyonrails-core
-~----------~----~----~----~------~----~------~--~---
|
|
| bug in routes ??? |

|
2006-09-21 19:26:20 |
|
Hi,
I tried passing a controller string of "/contacts" instead of "contacts" and this does work (thanks) however I don't quite understand the logic around this relative path behaviour in
routes.rb.
* If the controller itself is contacts_controller.rb and it is in the root (i.e. not a subdirectory) why would one be required to specify "/"
* Conversely what is gained by allowing specification of a relative controller, or more to the point, if one is specified as was the case here what is the logic behind allowing a URL to be greated by
routes.rb that does not match a route? Shouldn't the URL producing mechanism in routes.rb be matching the input parameters against available routes, such invalid URLs are not produced (i.e
. one that doesn't match a route)?
==================================== irb(#<#<Class:0x3775b58>:0x3775b28>):021:0* url_for :controller => "/contacts
" => "/en/contacts"
irb(#<#<Class:0x3775b58>:0x3775b28>):022:0> url_for :controller => "contacts
" => "/en/active_rbac/contacts"
irb(#<#<Class:0x3775b58>:0x3775b28>):023:0> params => {"action"=>"login", "controller"=>"active_rbac/login", "locale"=>"en"}
irb(#<#<Class:0x3775b58>:0x3775b28>):024:0> url_for => "/en/active_rbac/login/login"
====================================
Tks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core -~----------~----~----~----~------~----~------~--~---
|
| bug in routes ??? |

|
2006-09-21 20:28:17 |
|
PS. In fact using the "/" in the url_for (e.g. url_for :controller => "/contacts
") still seems to be an issue as rails doesn't resolve it. As an example:
===========routes.rb extract================= map.connect '/login/:en', :controller => 'active_rbac/login', :action => 'login'
map.splash ':locale', :controller => 'splash', :locale => nil map.connect ':locale/:controller/:action/:id', :defaults => { :controller => "splash" }
==========manual debug====================
irb(#<#<Class:0x38cd400>:0x38cd3d0>):005:0* params => {"action"=>"login", "controller"=>"active_rbac/login", "locale"=>"fr"}
irb(#<#<Class:0x38cd400>:0x38cd3d0>):006:0> url_for => "/fr/active_rbac/login/login"
irb(#<#<Class:0x38cd400>:0x38cd3d0>):007:0> url_for :controller => '
contacts', :action => 'list' => "/fr/active_rbac/contacts/list" <== NOT DESIRED URL, WILL NOT WORK, "active_rbac" should not appear
irb(#<#<Class:0x38cd400>:0x38cd3d0>):008:0> url_for :controller => '/contacts', :action => 'list' ActionController::RoutingError:
No url can be generated for the hash {:action=>"list", :controller=>"contacts"} from (druby://localhost:42531) generated_code/routing/generation.rb:198:in `generate_default_path'
from (druby://localhost:42531) C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:473:in `generate_path' from (druby://localhost:42531) C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-
1.12.5/lib/action_controller/routing.rb:469:in `generate' from (druby://localhost:42531) C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/url_rewriter.rb:44:in `rewrite_path'
from (druby://localhost:42531) C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/url_rewriter.rb:11:in `rewrite' from (druby://localhost:42531) C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-
1.12.5/lib/action_controller/base.rb:488:in `url_for' from (druby://localhost:42531) C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/url_helper.rb:27:in `url_for' from (druby://localhost:42531) (irb):8:in `breakpoint'
from (druby://localhost:42531) C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/breakpoint.rb:512:in `breakpoint' from (druby://localhost:42531) C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-
1.1.6/lib/breakpoint.rb:512:in `breakpoint' from (druby://localhost:42531) ./script/../config/../app/views/layouts/site_layout.rhtml:38:in `_run_rhtml_layouts_site_layout' from (druby://localhost:42531) C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-
1.12.5/lib/action_view/base.rb:316:in `compile_and_render_template' from (druby://localhost:42531) C:/InstantRails/ruby/lib/ruby/gems/1.8/gems | |