Is there a way to submit ajax/json requests with simple_form for Rails

后端 未结 5 1943
感情败类
感情败类 2021-01-05 09:43

With the standard Rails form_for, I was able to pass ajax requests though select and collection_select helpers as such:

<%= address.collection_select :cou         


        
5条回答
  •  离开以前
    2021-01-05 10:33

    It is better to write it like this:

    = simple_form_for sample_result, url: reject_sample_result_path(sample_result), method: :post, remote: true, input_html: {multipart: true} do |f|
    

    When you explicitly declare data-url it will still first do the default route calculation, which in my case failed because the default routes did not exist (and should not exist --since I am overruling the url). When you declare just url it will just take the given url instead.

提交回复
热议问题