Ticket: http://dev.rubyonrails.org/ticket/9183

(I've confirmed this is a problem with later updates of Rails 1.2.3 
gems, and not a specific problem to Hobo)

Named routes inside a route block broken

Beginning with the update after original Rails 1.2.3, named routes get 
broken when used inside a routing block.

There is a possibility (unconfirmed) that other routing capabilites 
(like nested resources?) are also problematic inside a block.

I've marked this as Critical because in my app, this bug effectively 
shuts down my entire site. :-( With no quick fix except for reverting to 
previously working Rails version. (that isn't "easy" due to the bug 
#7322 <http://dev.rubyonrails.org/ticket/7322>)

Sample code:

config/routes.rb:

  map.resources :bagus, :collection => {:aduh => :get} do |x|
          x.aduh '/nguk', :controller => 'bagus', :action => 'aduh'
  end

app/controllers/bagus.rb:

class BagusController < ApplicationController
  def aduh
    render :inline => 'text <%= aduh_path %> bages'
  end
end

Result:

 NameError in BagusController#aduh

undefined local variable or method `aduh_path' for 
#<ActionView::Base:0xb6804ba0>

RAILS_ROOT: /media/prestige/project/hobo/testr
Application Trace | Framework Trace | Full Trace

compiled-template:1:in `_run_2'
app/controllers/bagus_controller.rb:3:in `aduh'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_view/base.rb:350:in
 `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_view/base.rb:350:in
 `compile_and_render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_view/base.rb:326:in
 `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:884:in
 `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:817:in
 `render_with_no_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/layout.rb:258:in
 `render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/benchmarking.rb:51:in
 `render'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/benchmarking.rb:51:in
 `render'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:1136:in
 `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:1136:in
 `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/filters.rb:713:in
 `call_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/filters.rb:752:in
 `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/benchmarking.rb:68:in
 `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/benchmarking.rb:68:in
 `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/rescue.rb:133:in
 `perform_action_without_caching'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/caching.rb:663:in
 `perform_action'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3.7116/lib/active_record/query_cache.rb:99:in
 `cache'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/caching.rb:662:in
 `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:494:in
 `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:494:in
 `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/filters.rb:747:in
 `process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/session_management.rb:122:in
 `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:346:in
 `process'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3.7116/lib/dispatcher.rb:39:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in 
`synchronize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in 
`run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in 
`each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in 
`run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:127:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:488:in
 `load'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:488:in
 `load'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:342:in
 `new_constants_in'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:488:in
 `load'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3.7116/lib/commands/servers/mongrel.rb:64
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in 
`gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:495:in
 `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:342:in
 `new_constants_in'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:495:in
 `require'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3.7116/lib/commands/server.rb:39
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in 
`gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
script/server:3

compiled-template:1:in `_run_2'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_view/base.rb:350:in
 `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_view/base.rb:350:in
 `compile_and_render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_view/base.rb:326:in
 `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:884:in
 `render_template'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:817:in
 `render_with_no_layout'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/layout.rb:258:in
 `render_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/benchmarking.rb:51:in
 `render'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/benchmarking.rb:51:in
 `render'
app/controllers/bagus_controller.rb:3:in `aduh'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:1136:in
 `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:1136:in
 `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/filters.rb:713:in
 `call_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/filters.rb:752:in
 `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/benchmarking.rb:68:in
 `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/benchmarking.rb:68:in
 `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/rescue.rb:133:in
 `perform_action_without_caching'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/caching.rb:663:in
 `perform_action'
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.3.7116/lib/active_record/query_cache.rb:99:in
 `cache'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/caching.rb:662:in
 `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:494:in
 `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:494:in
 `process_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/filters.rb:747:in
 `process_without_session_management_support'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/session_management.rb:122:in
 `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3.7116/lib/action_controller/base.rb:346:in
 `process'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3.7116/lib/dispatcher.rb:39:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:78:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in 
`synchronize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:618:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:617:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:736:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel.rb:720:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:271:in 
`run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in 
`each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/configurator.rb:270:in 
`run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:127:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/lib/mongrel/command.rb:211:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.0.1/bin/mongrel_rails:243
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:488:in
 `load'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:488:in
 `load'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:342:in
 `new_constants_in'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:488:in
 `load'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3.7116/lib/commands/servers/mongrel.rb:64
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in 
`gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:495:in
 `require'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:342:in
 `new_constants_in'
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.2.7116/lib/active_support/dependencies.rb:495:in
 `require'
/usr/lib/ruby/gems/1.8/gems/rails-1.2.3.7116/lib/commands/server.rb:39
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in 
`gem_original_require'
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
script/server:3

Request

Parameters:

None

Show session dump

--- 
flash: !map:ActionController::Flash::FlashHash {}


Response

Headers:

{"cookie"=>[],
 "Cache-Control"=>"no-cache"}

Update: sake routes displays that the route is named 'person_kill' (for 
resources 'people' and action 'kill')

person_kill           ANY    //people/:person_id/hello/               
{:path_prefix=>"/people/:person_id", :name_prefix=>"person_", :action=>"index",
 :controller=>"people"}

Previous Rails version (1.2.3.original) would simply name the route as 
'kill'.

After reading the changelog for edge/trunk :

+* Prefix nested resource named routes with their action name, e.g. 
new_group_user_path(@group) instead of group_new_user_path(@group). The 
old nested action named route is deprecated in Rails 1.2.4. #8558 
<http://dev.rubyonrails.org/ticket/8558> [David Chelimsky]

I suspect the behavior changes yet again ('kill_person'?)

Workaround:

Use the new route name. It may change again in Rails 1.2.4 so simply be 
careful. :-)

Replacing the inner variable "x" with "map" works for a few situations. 
Using "connect" works, but this beats the purpose of named routes.

The "best" workaround is to use the old Rails 1.2.3 gems. Unfortunately, 
freezing still hasn't been working yet (bug #7322 
<http://dev.rubyonrails.org/ticket/7322>).

Used versions:

[EMAIL PROTECTED]:~/project/hobo/testr$ gem list | egrep 
'^action|^active|^rails '
actionmailer (1.3.3.7116)
actionpack (1.13.3.7116, 1.13.3.6548)
actionwebservice (1.2.3.6548)
activerecord (1.15.3.7116, 1.15.3.6548)
activeresource (0.9.0.7116)
activesupport (1.4.2.7116, 1.4.2.6548)
rails (1.2.3.7116)


-- 
Hendy Irawan
www.hendyirawan.com


--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to