簡體   English   中英

ShowTooltip窗口效果的AJAX + RAILS問題…Rails中的路由錯誤

[英]AJAX + RAILS Problem with ShowTooltip window effect…Routing Error in Rails

AJAX + RAILS問題。 我收到以下路由錯誤:

<div class="card-field">
  <h6><imgsrc="/images/red_icon.png" width="16" alt="" align="absmiddle" class="image-3"  onmouseover="ajax_showTooltip(window.event,'/quickadd_notes_help.html.erb?ranId='+Math.random(),this,'','');return false;"  /></h6>
 <p>Company Name:</p>
 <input type="text" name="company" id="company" size="50" />
 </div>

ActionController::RoutingError (No route matches "/quickadd_notes_help.html.erb" with {:method=>:post}):

不知道我在做什么錯。 我去時,控制器和視圖都工作正常

http://localhost:3000/cats
http://localhost:3000/cats/quickadd_notes_help

我嘗試了幾種修改HTML的方法!

window.event,'/quickadd_notes_help.html.erb?ranId='...
window.event,'/quickadd_notes_help?ranId='...
window.event,'/quickadd_notes_help.html?ranId='...

我有一個相同的示例,可以在托管的非Rails環境中正常工作。 但是似乎無法使它在Rails環境中工作。 我的routes.rb文件如下所示:

map.resources :cat

感謝您可以提供的任何幫助!

謝謝,席德

該操作是/quickadd_notes_help ,而不是/quickadd_notes_help.html.erb

<div class="card-field">
  <h6><imgsrc="/images/red_icon.png" width="16" alt="" align="absmiddle" class="image-3"  onmouseover="ajax_showTooltip(window.event,'/quickadd_notes_help?ranId='+Math.random(),this,'','');return false;"  /></h6>
 <p>Company Name:</p>
 <input type="text" name="company" id="company" size="50" />
</div>

另外,您應在適用的情況下使用Rails幫助器來生成路徑。 假設該路線稱為quickadd_notes_help

<div class="card-field">
  <h6><imgsrc="/images/red_icon.png" width="16" alt="" align="absmiddle" class="image-3"  onmouseover="ajax_showTooltip(window.event,'<%= quickadd_notes_help_path %>?ranId='+Math.random(),this,'','');return false;"  /></h6>
 <p>Company Name:</p>
 <input type="text" name="company" id="company" size="50" />
</div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM