2013-10-29 5 views
0

내 앱에서 라우팅에 문제가 있습니다. 그 이유는 모르겠습니다. 누군가가 왜 이렇게 설명 할 수 있기를 바랍니다.루비 온 레일스 라우트가 button_to로 발견되지 않았지만 link_to로 발견되지 않음

도움 주셔서 대단히 감사합니다.

<%= 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] "/ 드/레스토랑/526fe01e65617271ea000000" 추적 : actionpack (4.0. 0) LIB/action_dispatch/미들웨어/debug_exceptions.rb : 21 : call' actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in 호 ': 38 : railties (4.0.0) LIB/레일/랙/logger.rb 호출 call_app' railties (4.0.0) lib/rails/rack/logger.rb:21:in 블록'에 activesupport (4.0.0)를 lib/active_support/tagged_logging.rb : 67 : block in tagged' activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in에 태그 ' activesupport (4.0.0) lib/a ctive_support/tagged_logging.rb : 67 : tagged' railties (4.0.0) lib/rails/rack/logger.rb:21:in에서 actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb : 21 : call' rack (1.5.2) lib/rack/methodoverride.rb:21:in에서 ' 랙 (1.5.2) lib/rack/runtime.rb : 17 : call' activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in에서 ' 랙 (1.5.2) lib/rack/lock.rb : 17 : call' actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in에서 전화' railties (4.0.0) lib/rails/engine.rb : 511 : call' railties (4.0.0) lib/rails/application.rb:97:in 전화 ' 승객 (4.0.21) lib/phusion_passenger/rack/thread_handler_extension.rb : 77 : process_request' passenger (4.0.21) lib/phusion_passenger/request_handler/thread_handler.rb:140:in accept_and_process_next_request ' 승객 (4.0.21) lib/phusion_passenger/request_handler/thread_handler.rb : 108 : main_loop' passenger (4.0.21) lib/phusion_passenger/request_handler.rb:441:in 블록 (3 레벨) in start_threads'

개 경로

위에서 아래

도우미 HTTP 동사 경로 컨트롤러 # 작업 경로/URL
GET welcome_index_path (/:locale)/welcome(.:format)에 오신 것을 환영합니다 # 지수 POST에 우선 순위

경로 일치 (/ : 로칼 알)/환영합니다. : 서식) welcome # create new_welcome_path GET (/:locale)/welcome/new(.:format) welcome # new edit_welcome_path GET (/ : 로케일)/환영/: id/편집 (. : 형식) welcome # edit welcome_path GET (/:locale)/welcome/ : id(.:format) welcome # show PATCH (/:locale)/welcome/:id(.:format) welcome # update PUT (/:locale)/welcome/:id(.:format) welcome # update DELETE (/:locale)/welcome/ : id(.:format) welcome # destroy 레스토랑 _ 경로 GET (/ : 로케일)/레스토랑 (예 :/포맷) 레스토랑 # index 레스토랑 (예 :/:) 레스토랑 # create new_restaurant_path 레스토랑/신식 레스토랑 : new # edit_restaurant_path GET (/ :// 식당/: id/편집 (. : 형식) 식당 # 편집 레스토랑 _ 경로 GET (/ : 거리)/레스토랑/:(예 : 서식) 식당 # show PATCH (/ : 지역)/restaurants/: id (. : format) restaurants # update PUT (/:locale)/restaurants/ : id(.:format) 레스토랑 # update DELETE (/:locale)/restaurants/ : id(.:format) 레스토랑은 #을 파괴합니다.root_path GET/welcome # 색인

답변

2

기본적으로 button_to은 게시물을 게시하고 link_to은 가져 오기를 수행합니다.원하는 내용이므로

<%= button_to 'Show', restaurant_path(restaurant), :id => 'button_show_restaurant', :class => 'btn btn-success', :method => :get %> 
+0

안녕 Vidya, 빠른 답장을 보내 주셔서 감사합니다. 그것은 효과가 있었다. 설명 주셔서 대단히 감사합니다. – damir

+0

도와 드리겠습니다. 프로젝트에 행운을 빌어 요! – Vidya