简体   繁体   English

Rails Ajax response_to js错误

[英]Rails ajax respond_to js error

I was following this tutorial , but I encountered some troubles. 我正在关注本教程 ,但是遇到了一些麻烦。 I got an controller method called sort_new_section , and in the erb , it would use ajax to trigger this controller. 我有一个名为sort_new_section的控制器方法,在erb ,它将使用ajax来触发该控制器。 Then response to its js.erb and render a partial view. 然后响应其js.erb并呈现局部视图。

In create_question_controller create_question_controller中

def sort_new_seciton 
...
    @sort_volume = volume
    respond_to do |format|
        format.js   
    end
end

In view/create_question/sort_new_section.js.erb view / create_question / sort_new_section.js.erb中

$('#xxx').append("<%= j render :partial => 'create_question/section_in_panel', :locals => {:volume_id => @sort_volume, } %>");

However, it threw this error. 但是,它引发了此错误。

ActionView::MissingTemplate (Missing template user_create_question/sort_new_seciton, create_question/sort_new_seciton, application/sort_new_seciton with {:locale=>[:"zh-TW", :en], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee]}.

The error says sort_new_seciton , not sort_new_section . 错误显示为sort_new_seciton ,而不是sort_new_section

ActionView::MissingTemplate (Missing template user_create_question/sort_new_seciton, create_question/sort_new_seciton, application/sort_new_seciton with {:locale=>[:"zh-TW", :en], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee]}.

Looks like you have a typo in your code. 看起来您的代码中有错字。 Specifically, look at your controller method. 具体来说,请看您的控制器方法。 It's sort_new_seciton . 这是sort_new_seciton

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM