【发布时间】:2013-10-29 16:48:46
【问题描述】:
我的应用程序中的路由出现问题,但我不明白为什么。 我希望有人能解释一下为什么会这样。
非常感谢您的帮助。
<%= link_to 'Show', restaurant_path(restaurant), :id => 'button_show_restaurant', :class => 'btn btn-success' %>
<%= button_to 'Show', restaurant_path(restaurant), :id => 'button_show_restaurant', :class => 'btn btn-success' %>
link_to 代码正确路由到所需餐厅,但 button_to 产生以下内容:
没有路线匹配 [POST] "/de/restaurants/526fe01e65617271ea000000"
痕迹:
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:incall'
railties (4.0.0) lib/rails/rack/logger.rb:38:in call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:inblock in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:intagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:incall'
actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in call'
rack (1.5.2) lib/rack/methodoverride.rb:21:incall'
机架 (1.5.2) lib/rack/runtime.rb:17:in call'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:incall'
机架 (1.5.2) lib/rack/lock.rb:17:in call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:incall'
railties (4.0.0) lib/rails/engine.rb:511:in call'
railties (4.0.0) lib/rails/application.rb:97:incall'
乘客 (4.0.21) lib/phusion_passenger/rack/thread_handler_extension.rb:77:in process_request'
passenger (4.0.21) lib/phusion_passenger/request_handler/thread_handler.rb:140:inaccept_and_process_next_request'
乘客 (4.0.21) lib/phusion_passenger/request_handler/thread_handler.rb:108:in main_loop'
passenger (4.0.21) lib/phusion_passenger/request_handler.rb:441:inblock (3 个级别) in start_threads'
路线
路由从上到下优先匹配
Helper HTTP 动词路径控制器#Action
路径/网址
welcome_index_path GET (/:locale)/welcome(.:format) 欢迎#index
POST (/:locale)/welcome(.:format) 欢迎#create
new_welcome_path GET (/:locale)/welcome/new(.:format) Welcome#new
edit_welcome_path GET (/:locale)/welcome/:id/edit(.:format) Welcome#edit
welcome_path GET (/:locale)/welcome/:id(.:format) 欢迎#show
PATCH (/:locale)/welcome/:id(.:format) 欢迎#update
PUT (/:locale)/welcome/:id(.:format) 欢迎#update
删除 (/:locale)/welcome/:id(.:format) Welcome#destroy
restaurant_path GET (/:locale)/restaurants(.:format) 餐厅#index
POST (/:locale)/restaurants(.:format) 餐厅#create
new_restaurant_path GET (/:locale)/restaurants/new(.:format) 餐厅#new
edit_restaurant_path GET (/:locale)/restaurants/:id/edit(.:format) 餐厅#edit
restaurant_path GET (/:locale)/restaurants/:id(.:format) 餐厅#show
PATCH (/:locale)/restaurants/:id(.:format) 餐厅#update
PUT (/:locale)/restaurants/:id(.:format) 餐厅#update
删除 (/:locale)/restaurants/:id(.:format) 餐厅#destroy
root_path GET / 欢迎#index
【问题讨论】:
标签: ruby-on-rails routing link-to button-to