2011-02-10 60 views
1

我已经设置意见与AJAX默许了整个下午,并断枝突然一个,给我这个错误:Rails突然需要一个模板..当它在那里?

ActionView::MissingTemplate (Missing template tabs/tabs_result.erb in view path app/views:vendor/plugins/rails-ckeditor/app/views): 

奇怪..

我的路线

organization.resources :tabs, :collection => {:tabs_result => :get} 

产生此路线:

tabs_result_organization_tabs GET /organizations/:organization_id/tabs/tabs_result(.:format) 

我从来不需要在控制器中的操作,所以我只是跳过。

我这里有一个文件/tabs/tabs_result.js.haml

我叫它这一行:

= link_to tab.title, tabs_result_organization_tabs_path(organization, tab), :class => 'show-result' 

任何人都知道这是为什么错误弹出?

我想我还要指出的是,如果我改名的文件时,它tabs_result.js.erb即使它不是,我不希望它是,它给了我这个错误:

ActionController::UnknownAction (No action responded to tabs_result. Actions: create, destroy, edit, edit_order, new, show, update, and update_order): 
+1

检查,看看你的控制器被格式化返回format.js用于执行该操作。 – Dominic 2011-02-10 20:42:18

回答

1

您需要告诉rails你正在请求一个Ajax响应。

我假设你试图在“点击”事件后呈现响应。

所以所有的链接,您可以添加一个名为“ajaxLink”类,并添加下面的jQuery代码

$(document).ready(function(){ 
    $("a.ajaxLink").live("click", function(){ 
    $.getScript($(this).attr("href")); 
    return false; 
    }); 
}