Rails 405 方法不允许

发布于 2024-09-16 00:54:16 字数 920 浏览 4 评论 0原文

我有一个选择框,每次更改时我都会返回控制器并获取一些数据。然后将该数据加载到 div 中。

jQuery:

   $('#groups').change(function() {
       $('#emails').load('/notifications/get', {value: $(this).val()});
  });

Controller:

  class NotificationsController < ApplicationController
      def get
        return "test"
      end
  end

View:

  <div id="groups" class="left">
<%=select_tag 'employee[group_id][]', options_for_select( current_user.groups.map {|s| ["#{s.name} - #{s.description} (" + s.employees.find(:all, :conditions=>{:subscribed=>true}).count.to_s+")", s.id]}), :multiple => true, :size =>6, :style  => "width:250px"%>
  </div>

  <p id="emails"> </p>

当我尝试使用 firebug 进行调试时,我看到错误是 405 method not allowed ..进一步返回的响应说

仅获取、放置和删除
允许请求。

I have a select box and on every change I am going back to my controller and fetching some data. This data is then loaded into a div.

jQuery:

   $('#groups').change(function() {
       $('#emails').load('/notifications/get', {value: $(this).val()});
  });

Controller:

  class NotificationsController < ApplicationController
      def get
        return "test"
      end
  end

View:

  <div id="groups" class="left">
<%=select_tag 'employee[group_id][]', options_for_select( current_user.groups.map {|s| ["#{s.name} - #{s.description} (" + s.employees.find(:all, :conditions=>{:subscribed=>true}).count.to_s+")", s.id]}), :multiple => true, :size =>6, :style  => "width:250px"%>
  </div>

  <p id="emails"> </p>

When I try to debug with firebug I see that error is 405 method not allowed ..furthermore response that comes back says

Only get, put, and delete
requests are allowed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉鱼一梦 2024-09-23 00:54:16

您是否为该操作设置了路线?

Do you have a route set for that action?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文