2016-08-27 22 views
0

私はこれをフォローしていたtutorialですが、いくつかの問題が発生しました。 sort_new_sectionというコントローラーメソッドがあり、erbにはajaxを使用してこのコントローラーをトリガーします。その後、js.erbに応答し、部分的な表示を行います。Rails ajax respond_to jsエラー

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

ビュー/ create_question/sort_new_section.js.erb

create_question_controllerで

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

しかし、このエラーを投げました。

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]}. 
+0

あなたは 'respond_to'セクションなしで試してみませんか? – Aleksey

+0

あなたのビューパスを確認してください。あなたが書いたように、 'view/path/to'は' view/... 'ではありません。 – Aleksey

答えて

1

エラーが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]}. 

コードに誤字があるようです。具体的には、コントローラのメソッドを見てください。それはsort_new_secitonです。

+0

ありがとう!それは私のせいです。 –

関連する問題