【发布时间】:2012-10-10 01:23:16
【问题描述】:
我似乎无法让 thoughtbot's High Voltage gem 用于不以 /pages 开头的 URL。对于像www.example.com/pages/company/about 这样的 URL,它工作得很好。当我添加这条路线时:
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'
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 rubygems gem ruby-on-rails-3.2