使用/ blog /:year /:month /:day在Ruby on Rails中为博客命名路由

时间:2011-03-03 17:43:23

标签: ruby-on-rails routes custom-routes

我的网站内置的某些路线似乎有点问题。我确定 正在工作,但自从我在这个网站上工作以来已经有一段时间了。不明白为什么它现在不起作用。如果有人能对我有所了解,那将非常感谢,谢谢!

错误:

ActionController::RoutingError in Articles#show

Showing app/views/articles/_archive.html.erb where line #4 raised:

blog_url failed to generate from {:action=>"index", :controller=>"articles", :month=>3, :year=>2011}, expected: {:controller=>"articles", :action=>"index"}, diff: {:month=>3, :year=>2011}

Extracted source (around line #4):

1: <h2 class="red_heading"><span>Archive</span></h2>
2: <ul id="archive" class="sub_list">
3:  <% @articles_months.each do |group, articles| %>
4:      <li><%= link_to("#{group.strftime('%B')}, #{group.strftime('%Y')}", blog_url(group.year, group.month)) %></li>
5:  <% end %>
6: </ul>

Trace of template inclusion: app/views/articles/show.html.erb

RAILS_ROOT: /Users/peterroome/Sites/thelondoncubanallstars.com
Application Trace | Framework Trace | Full Trace

/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/routing/route_set.rb:427:in `raise_named_route_error'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/routing/route_set.rb:388:in `generate'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/url_rewriter.rb:216:in `rewrite_path'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/url_rewriter.rb:195:in `rewrite_url'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/url_rewriter.rb:173:in `rewrite'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:625:in `url_for'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/helpers/url_helper.rb:85:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/helpers/url_helper.rb:85:in `url_for'
(eval):17:in `blog_url'
/Users/peterroome/Sites/thelondoncubanallstars.com/app/views/articles/_archive.html.erb:4:in `_run_erb_app47views47articles47_archive46html46erb_locals_archive_object'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/ordered_hash.rb:115:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/ordered_hash.rb:115:in `each'
/Users/peterroome/Sites/thelondoncubanallstars.com/app/views/articles/_archive.html.erb:3:in `_run_erb_app47views47articles47_archive46html46erb_locals_archive_object'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:306:in `with_template'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:30:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable_partial.rb:20:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:26:in `benchmark'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:26:in `benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable_partial.rb:19:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/template.rb:205:in `render_template'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable_partial.rb:44:in `render_partial'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/partials.rb:184:in `render_partial'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:267:in `render'
/Users/peterroome/Sites/thelondoncubanallstars.com/app/views/articles/show.html.erb:5:in `_run_erb_app47views47articles47show46html46erb'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:306:in `with_template'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:30:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/template.rb:205:in `render_template'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:265:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:348:in `_render_with_layout'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:262:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:1250:in `render_for_file'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:942:in `render_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:51:in `render'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:51:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:135:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:135:in `custom'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:179:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:179:in `respond'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:173:in `each'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:173:in `respond'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:107:in `respond_to'
/Users/peterroome/Sites/thelondoncubanallstars.com/app/controllers/articles_controller.rb:52:in `show'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:1331:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:1331:in `perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:617:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:638:in `run_before_filters'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:185:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:185:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:186:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:635:in `run_before_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:615:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/flash.rb:151:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:532:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:532:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:606:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:391:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:386:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/routing/route_set.rb:438:in `call'

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/Users/peterroome/Sites/thelondoncubanallstars.com/vendor/plugins/acts_as_friendly_param/lib/friendly_filter.rb:26:in `filter'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:87:in `dispatch'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:121:in `_call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:114:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:108:in `call'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
script/server:3:in `require'
script/server:3

/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/routing/route_set.rb:427:in `raise_named_route_error'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/routing/route_set.rb:388:in `generate'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/url_rewriter.rb:216:in `rewrite_path'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/url_rewriter.rb:195:in `rewrite_url'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/url_rewriter.rb:173:in `rewrite'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:625:in `url_for'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/helpers/url_helper.rb:85:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/helpers/url_helper.rb:85:in `url_for'
(eval):17:in `blog_url'
/Users/peterroome/Sites/thelondoncubanallstars.com/app/views/articles/_archive.html.erb:4:in `_run_erb_app47views47articles47_archive46html46erb_locals_archive_object'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/ordered_hash.rb:115:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/ordered_hash.rb:115:in `each'
/Users/peterroome/Sites/thelondoncubanallstars.com/app/views/articles/_archive.html.erb:3:in `_run_erb_app47views47articles47_archive46html46erb_locals_archive_object'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:306:in `with_template'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:30:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable_partial.rb:20:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:26:in `benchmark'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:26:in `benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable_partial.rb:19:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/template.rb:205:in `render_template'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable_partial.rb:44:in `render_partial'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/partials.rb:184:in `render_partial'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:267:in `render'
/Users/peterroome/Sites/thelondoncubanallstars.com/app/views/articles/show.html.erb:5:in `_run_erb_app47views47articles47show46html46erb'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:34:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:306:in `with_template'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/renderable.rb:30:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/template.rb:205:in `render_template'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:265:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:348:in `_render_with_layout'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_view/base.rb:262:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:1250:in `render_for_file'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:942:in `render_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:51:in `render'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:51:in `render'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:135:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:135:in `custom'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:179:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:179:in `respond'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:173:in `each'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:173:in `respond'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/mime_responds.rb:107:in `respond_to'
/Users/peterroome/Sites/thelondoncubanallstars.com/app/controllers/articles_controller.rb:52:in `show'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:1331:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:1331:in `perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:617:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:638:in `run_before_filters'
/Users/peterroome/Sites/thelondoncubanallstars.com/vendor/plugins/acts_as_friendly_param/lib/friendly_filter.rb:26:in `filter'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:185:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/callbacks.rb:185:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:186:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:635:in `run_before_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:615:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.9/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/rescue.rb:160:in `perform_action_without_flash'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/flash.rb:151:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:532:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:532:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/filters.rb:606:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:391:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/base.rb:386:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/routing/route_set.rb:438:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:87:in `dispatch'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:121:in `_call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:130:in `build_middleware_stack'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:29:in `call'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:29:in `call'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:9:in `cache'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.9/lib/active_record/query_cache.rb:28:in `call'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/string_coercion.rb:25:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/head.rb:9:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/methodoverride.rb:24:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/params_parser.rb:15:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/session/cookie_store.rb:100:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/failsafe.rb:26:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/lock.rb:11:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/lock.rb:11:in `synchronize'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/lock.rb:11:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:114:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/reloader.rb:34:in `run'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.9/lib/action_controller/dispatcher.rb:108:in `call'
/Library/Ruby/Gems/1.8/gems/rails-2.3.9/lib/rails/rack/static.rb:31:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/urlmap.rb:47:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/urlmap.rb:41:in `each'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/urlmap.rb:41:in `call'
/Library/Ruby/Gems/1.8/gems/rails-2.3.9/lib/rails/rack/log_tailer.rb:17:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/content_length.rb:13:in `call'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/handler/webrick.rb:48:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
/Library/Ruby/Gems/1.8/gems/rack-1.1.1/lib/rack/handler/webrick.rb:14:in `run'
/Library/Ruby/Gems/1.8/gems/rails-2.3.9/lib/commands/server.rb:111
script/server:3:in `require'
script/server:3

Request

Parameters:

{"id"=>"48-another-jazzy-event"}

Show session dump

--- 

Response

Headers:

{"Content-Type"=>"text/html",
 "Cache-Control"=>"no-cache"}

查看:

<h2 class="red_heading"><span>Archive</span></h2>
<ul id="archive" class="sub_list">
    <% @articles_months.each do |group, articles| %>
        <li><%= link_to("#{group.strftime('%B')}, #{group.strftime('%Y')}", blog_url(group.year, group.month)) %></li>
    <% end %>
</ul>

路线:

  map.blog '/blog/:year/:month/:day', :controller => 'articles', 
                                      :action => 'index',
                                      :year => nil,
                                      :month => nil,
                                      :day => nil,
                                      :requirements => {:year => /\d{4}/,
                                                        :month => /\d{2}/,
                                                        :day => /\d{2}/}

2 个答案:

答案 0 :(得分:0)

你不应该把这样的博客网址过去吗?

blog_url(group.year, group.month, group.day)

答案 1 :(得分:0)

被我自己:requirements难倒。月份需要以03而不是3传递。已修复:group.strftime('%m')