[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
-~----------~----~----~----~------~----~------~--~---
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 -~----------~----~----~----~------~----~------~--~---
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
-~----------~----~----~----~------~----~------~--~---
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/actionpack-1.12.5/lib/action_view/base.rb:292:in
`render_template''
from (druby://localhost:42531)
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in
`render_file''
from (druby://localhost:42531)
./script/../config/../config/nested_layout.rb:7:in `inside_layout''
from (druby://localhost:42531)
./script/../config/../app/views/layouts/login_layout.rhtml:9:in
`_run_rhtml_layouts_login_layout''... 49 levels...
from C:/InstantRails/ruby/lib/ruby/1.8/drb/drb.rb:1512:in
`perform''
from C:/InstantRails/ruby/lib/ruby/1.8/drb/drb.rb:1586:in
`main_loop''
from C:/InstantRails/ruby/lib/ruby/1.8/drb/drb.rb:1582:in
`main_loop''
from C:/InstantRails/ruby/lib/ruby/1.8/drb/drb.rb:1578:in
`main_loop''
from C:/InstantRails/ruby/lib/ruby/1.8/drb/drb.rb:1427:in `run''
from C:/InstantRails/ruby/lib/ruby/1.8/drb/drb.rb:1424:in `run''
from C:/InstantRails/ruby/lib/ruby/1.8/drb/drb.rb:1344:in
`initialize''
from C:/InstantRails/ruby/lib/ruby/1.8/drb/drb.rb:1624:in
`start_service''
from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6
/lib/breakpoint_client.rb:146
from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6
/lib/breakpoint_client.rb:145
from
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
from
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require''
from C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6
/lib/commands/breakpointer.rb:1
from
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
from
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require''
from
script/breakpointer:3irb(#<#<Class:0x38cd400>:0x38cd3d0>):009:0>
================================================
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Hi,
I''m still battling this one and am yet unsure whether this is a bug or
not.
It would be great if someone could put me out of my misery and confirm
whether this is bug or not?
With the latest testing to characterise the problem it seems to be something
to do with (a) controllers a sub-directory down &/or (b) url_for usage in a
layout perhaps. That is in the sense that I have a "url_for" which
resolves
find when the context is one controller but throws an error when in the
context of another.
Key points include:
1. routes.rb routes a URL to a controller which is down 1 subdirectory
- Example
map.connect '':locale/mygoodness'', :controller =>
''highlevel/midlevel'',
:action => ''testaction'', :defaults => {:locale =>
nil}
map.connect '':locale/contactbackdoor'', :controller =>
"contacts",
:defaults => {:locale => nil}
2. controller picks this up ok
class Highlevel::MidlevelController < ApplicationController
def testaction
puts "Highlevel::MidlevelController - testaction"
end
end
3. the "views/highlevel/midlevel/testaction.rhtml" view is small as
the application.rb has a layout "site_layout" line.
4. The "site_layout" has
<%= link_to "2-contacts ", :controller =>
''contacts'' %>
5. The site_layout link is generator OK when it is used from the
opening page, BUT when it is utilised after a URL has come in via the
controller which is down a sub-directory (i.e. ''highlevel/midlevel)
an
error is encountered. See below.
1. Note the hash indicated in the error below has "
:controller=>"highlevel/contacts" and it has seemed to munge
the
"highlevel/midlevel" controller name with the
"contacts" controller name.
2. Interestingly if I change the "url_for" line in the layout
to:
- <%= link_to "2-contacts ", :controller => nil %> one
sees the
following in the error :controller=>"
highlevel/highlevel/midlevel"
- <%= link_to "2-contacts ", :controller =>
"" %> one sees
the following in the error
:controller=>"highlevel/"
==============================================ActionController::RoutingError in
Highlevel/midlevel#testaction
Showing *app/views/layouts/site_layout.rhtml* where line *#15* raised:
No url can be generated for the hash {:action=>"index",
:controller=>"highlevel/contacts"}
Extracted source (around line *#15*):
12:
13: <p> <%= link_to "1 " %> </p>
14:
15: <p> <%= link_to "2-contacts ", :controller =>
''contacts'' %> </p>
16:
17: <p> <%#= link_to "Plugin Login", {:controller =>
''/rbac/login'', :action => ''login''}
%></p>
18:
RAILS_ROOT: ./script/../config/..
Application Trace <http://localhost:3001/en/mygoodness#> | Framework
Trace<http://localhost:3001/en/mygoodness#>| Full
Trace <http://localhost:3001/en/mygoodness#>
generated_code/routing/generation.rb:65:in `generate_default_path''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:473:in
`generate_path''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:469:in
`generate''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/url_rewriter.rb:44:in
`rewrite_path''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/url_rewriter.rb:11:in
`rewrite''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:488:in
`url_for''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/url_helper.rb:27:in
`url_for''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/url_helper.rb:59:in
`link_to''
#{RAILS_ROOT}/app/views/layouts/site_layout.rhtml:15:in
`_run_rhtml_layouts_site_layout''
-e:4
generated_code/routing/generation.rb:65:in `generate_default_path''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:473:in
`generate_path''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:469:in
`generate''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/url_rewriter.rb:44:in
`rewrite_path''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/url_rewriter.rb:11:in
`rewrite''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:488:in
`url_for''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/url_helper.rb:27:in
`url_for''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/url_helper.rb:59:in
`link_to''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in
`compile_and_render_template''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in
`render_template''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in
`render_file''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/layout.rb:251:in
`render_without_benchmark''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:53:in
`render''
C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:53:in
`render''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:942:in
`perform_action_without_filters''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in
`perform_action_without_benchmark''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in
`perform_action''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
`process_without_filters''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in
`process_without_session_management_support''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in
`process''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in
`dispatch''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in
`handle_dispatch''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in
`service''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in
`service''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:173:in
`start_thread''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:162:in
`start_thread''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in
`dispatch''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require''
script/server:3
generated_code/routing/generation.rb:65:in `generate_default_path''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:473:in
`generate_path''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:469:in
`generate''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/url_rewriter.rb:44:in
`rewrite_path''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/url_rewriter.rb:11:in
`rewrite''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:488:in
`url_for''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/url_helper.rb:27:in
`url_for''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/helpers/url_helper.rb:59:in
`link_to''
#{RAILS_ROOT}/app/views/layouts/site_layout.rhtml:15:in
`_run_rhtml_layouts_site_layout''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:316:in
`compile_and_render_template''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:292:in
`render_template''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/base.rb:251:in
`render_file''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/layout.rb:251:in
`render_without_benchmark''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:53:in
`render''
C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:53:in
`render''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:942:in
`perform_action_without_filters''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in
`perform_action_without_benchmark''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
C:/InstantRails/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in
`perform_action''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
`process_without_filters''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in
`process_without_session_management_support''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in
`process''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in
`dispatch''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in
`handle_dispatch''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in
`service''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in
`service''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:173:in
`start_thread''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:162:in
`start_thread''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start''
C:/InstantRails/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in
`dispatch''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
C:/InstantRails/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
`require''
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require''
script/server:3
===========================================-e:4
Request
*Parameters*: {"locale"=>"en"}
Show session dump <http://localhost:3001/en/mygoodness#>
---
flash: !map:ActionController::Flash::FlashHash {}
Response *Headers*: {"Status"=>"200 OK",
"cookie"=>[],
"Cache-Control"=>"no-cache"}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
> Hi, > > I''m still battling this one and am yet unsure whether this is a bug or not. > It would be great if someone could put me out of my misery and confirm > whether this is bug or not? > > With the latest testing to characterise the problem it seems to be something > to do with (a) controllers a sub-directory down &/or (b) url_for usage in a > layout perhaps. That is in the sense that I have a "url_for" which resolves > find when the context is one controller but throws an error when in the > context of another.If you want your url_for calls to work from both the top level, and controllers in modules, you need to use: :controller=>''/the_controller'' Otherwise it assumes it''s a relative link and generates links accordingly. Another (simpler) option is just to use a named route. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
creating subdirectories inside the controller directory is just gonna create problem some time or another. I''m not surprise to see this problem. On 9/24/06, Michael Koziarski <michael@koziarski.com> wrote:> > > > Hi, > > > > I''m still battling this one and am yet unsure whether this is a bug or > not. > > It would be great if someone could put me out of my misery and confirm > > whether this is bug or not? > > > > With the latest testing to characterise the problem it seems to be > something > > to do with (a) controllers a sub-directory down &/or (b) url_for usage > in a > > layout perhaps. That is in the sense that I have a "url_for" which > resolves > > find when the context is one controller but throws an error when in the > > context of another. > > If you want your url_for calls to work from both the top level, and > controllers in modules, you need to use: > > :controller=>''/the_controller'' > > Otherwise it assumes it''s a relative link and generates links > accordingly. Another (simpler) option is just to use a named route. > > > > -- > Cheers > > Koz > > > >-- gcc -O0 -DRUBY_EXPORT -rdynamic -Wl,-export-dynamic -L. main.o -lruby-static -ldl -lcrypt -lm -o ruby Everyone is trying their hardest to do their job but management has set it up so that it''s impossible. Take the control over your money, track your expenses http://justbudget.com Mathieu --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''m still following up on Michael''s suggestion but the context of the issue for me was use of the "activeRBAC" plugin/engine which does use the multiple level (e.g. plugin name = active_rbac, and under the app/controller they have a subdirectory called "active_rbac" where the controllers reside. Also I am housing links to these controllers in a common layout rhtml file hence the need for it to work from various spots. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> creating subdirectories inside the controller directory is just gonna create > problem some time or another. I''m not surprise to see this problem.We make extensive use of controllers in modules and have had very few problems. Tobi at shopify makes extensive use too. We''ve had no trouble and I''m not sure what you''re basing your opinion on. Greg''s situation is complicated by the use of engines, perhaps ask on their mailing list. Can you reproduce it without engines Greg? -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Interesting...I''ve been going through step by step with a small test
app:
1. multiple sub-directory in standard application => works OK using
absolute
"/" at the front of the controller value specified in a
"link_to"
2. installed engine plugin and moved the multiple sub-directory
controller/view to my test engine => worked ok again with absolute value
3. moved the links (link_to''s) from the individual views to an
application
wide layout => seemed to work ok again
4. introduced the :locale into the routes, and after some adjustments
(i.e. putting in a default :locale of nil for each route) got this
working too
In short using the (a) absolute path in the "link_to" and (b)
appropriate
use of a default :locale of nil, seem to have things working in a small test
app. I was getting errors previously in my full blown application when
playing with some of these tweaks so I''m not sure what went wrong :(
I''ll
go back to my full blown application again and see if I can spot something.
Any comments?
Cheers
Greg
PS routes.rb file from test application
====================================ActionController::Routing::Routes.draw do
|map|
map.connect '':locale/singlelevel'',
:controller => ''single'', :action =>
''testaction'',
:defaults => {:locale => ''nil''}
map.connect '':locale/multilevel'',
:controller => ''parent/child'', :action =>
''testaction'',
:defaults => {:locale => ''nil''}
map.connect '':locale'',
:controller => ''single'', :action =>
''index'',
:defaults => {:locale => ''nil''}
end
====================================
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
I think I have it! I''ve reproduced this without using a plugin or
engines,
so the behaviour is to do with rails. Question is whether this is expected
behaviour or not? Or whether it should be expected behaviour for rails:
Assumptions
[1] To allow a link_to entry to be populated in an application wide layout
it needs to work from anywhere. The suggested mechanism to achieve this is
by putting a "/" at the front of the ":controller =>
''/xxx''" part of
"link_to" to make it absolute
[2] If a route starts with say ":locale" (e.g.
"map.connect'':locale/grandad'', etc") then when
constructing a link_to
there is no need
to put this in place as it should be automatically populated if there is a
'':locale'' variable in params. This seems to generally work.
Issue
[3] When a "link_to" entry in a view file uses the absolute path
approach
(from [1] above) it would seem that it then prevents the concept described
in [2] from occuring.
Possible Workarounds
[4] Placing a default value of :locale in the routes.rb route gets the
link_to to generate however obviously that won''t really help by
hard-coding
a specific locale in. That is this routes.rb default seems to be used in
the link_to generation, even though an available params[:locale] parameter
will not.
[5] Placing dynamically generated value for :locale in every link_to. Not
ideal from a DRY concept. Example:
link_to ''my link'', { :locale =>
''#{params[:locale]}'', :controller
=> ''/parent/child'', :action =>
''testaction'' }
Resolution
[6] Update to rails (routes.rb??) to allow a "params" value to be used
when
constructing a link_to or url_for even when the specified controller is an
absolute path (e.g. / ).
Aside - I still don''t really understand why rails would allow the
concept of
specifying relative and absolute controllers? Shouldn''t they all be
absolute?
Comments? Do people agree?
Tks
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
-~----------~----~----~----~------~----~------~--~---
Hello Greg, 2006/9/25, Greg Hauptmann <greg.hauptmann.ruby@gmail.com>:> [5] Placing dynamically generated value for :locale in every link_to. Not > ideal from a DRY concept. Example: > link_to 'my link', { :locale => '#{params[:locale]}', :controller > => '/parent/child', :action => 'testaction' }Take a look at default_url_options: http://api.rubyonrails.com/classes/ActionController/Base.html#M000208 That is the best way to implement #5. Hope that helps ! -- 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 -~----------~----~----~----~------~----~------~--~---
thanks Francois - this worked for me. I think my suggestion still probably stands however no? i.e. there would be situations where this may still be required. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---