high_voltage gem不适用于不以/ pages开头的URL

时间:2012-10-10 01:23:16

标签: ruby-on-rails ruby-on-rails-3 rubygems gem ruby-on-rails-3.2

我似乎无法使thoughtbot's High Voltage gem适用于不以/pages开头的网址。对于像www.example.com/pages/company/about这样的网址,它可以完美运行。当我添加这条路线时:

match '/company/about' => 'high_voltage/pages#show', :id => 'about'

我收到内部服务器错误:

Started GET "/company/about" for 127.0.0.1 at 2012-10-09 18:03:45 -0700
Processing by HighVoltage::PagesController#show as HTML
  Parameters: {"id"=>"about"}
Completed 500 Internal Server Error in 2ms

ActionController::RoutingError (No such page: about):
  high_voltage (1.2.0) app/controllers/high_voltage/pages_controller.rb:9:in `block in <class:PagesController>'
  activesupport (3.2.8) lib/active_support/rescuable.rb:80:in `call'
  activesupport (3.2.8) lib/active_support/rescuable.rb:80:in `rescue_with_handler'
  actionpack (3.2.8) lib/action_controller/metal/rescue.rb:15:in `rescue_with_handler'

但是,如果我只是将about.html.erb页面放在app/views/pages/about.html.erb内,那么这条路线的一切都按预期工作:

match '/:id' => 'high_voltage/pages#show'

或这条路线也有效:

match '/about' => 'high_voltage/pages#show', :id => 'about'

1 个答案:

答案 0 :(得分:0)

GitHub的jferris告诉我,我必须在上面写上“公司/关于”的ID。这很有用。