ActionController::UnknownFormat with format.js for ajax implementation (Rail 4)

前端 未结 3 1540
难免孤独
难免孤独 2021-01-11 09:41

i try to use Ajax in my application with Rails 4. To send my js to the client i use :

   respond_to do |format|
        format.js 
   end

3条回答
  •  甜味超标
    2021-01-11 09:49

    If you can use link_to helper function to call action of your controller, in your case Oweb::MainController#setmagasinstatus adding :remote => true to link_to helper will solve the issue.

    For example if you have a link to your action and want to get response in ajax the following code will create the link to that action:

    <%= link_to your_link_name, setmagasinstatus_path(:params), :remote => true %>

    Here is a dead easy sample https://coderwall.com/p/kqb3xq/rails-4-how-to-partials-ajax-dead-easy

提交回复
热议问题