Rails ajax一直在尝试渲染模板

时间:2014-05-02 08:48:32

标签: ruby-on-rails ajax ruby-on-rails-3

我使用Rails .js.erb ajax来触发控制器操作而不渲染模板,这是一项非常简单的任务。

但无论我尝试什么,Rails都会尝试每次都渲染一个模板

目前我的代码看起来像这样

  <%= form_tag change_index_superadmin_shops_path, remote: true do %>
    <select id = "live_select" name = "table[live]">
      <option value="false">All</option>
      <option value="true">Live</option>
    </select>
  <% end %>

和我的路线

namespace :superadmin do
  resources :shops do
    collection do
      post :change_index
      get :index_recurring_credit
    end
  end
end

和我的控制器

  def change_index
    @shops = Shop.where(live: true)
  end

那么为什么我得到一个&#34;模板丢失&#34;即使我在表单上声明了remote: true,也会出错?我该如何解决这个问题。

PS我确实有一个change_index.js.erb文件

0 个答案:

没有答案