Rails form_for :remote=>true is not calling js method

前端 未结 7 1716
感情败类
感情败类 2020-12-01 09:11

I have no idea why this is not working, I\'m learning rails and I\'m following a book it says to do it like this:

    <%= form_for([@article,@article.comm         


        
7条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 09:41

    Check the controller: does it have a respond_to block?

    If you generated your app with rails generate scaffold, it will have something like

        respond_to do |format|
          format.html
          format.xml  { .... }
        end
    

    If it does have it, just take the whole block out, from respond_to to end; or alternatively replace the whole block with the single line

        respond_to :html, :js
    

    or alternatively edit the block by adding the extra line shown here

        respond_to do |format|
          format.html
          format.js
          format.xml  { .... }
        end
    

    Either should work in your case.

提交回复
热议问题