【问题标题】:rails 3: update_attributes doesnt update and responds with 422 HTML Status Coderails 3:update_attributes 不更新并以 422 HTML 状态码响应
【发布时间】:2013-08-14 10:30:02
【问题描述】:

我使用 Ruby 3.2.13、Best_in_place 和 Mongoid。当我想更新我的集合选择的 mongodb 记录时,它不起作用并以 422 HTML 状态代码响应。其他所有字段都会正确更新。该系列由另一个模型组成。

这是我的更新定义:

def update
    @book = Book.find(params[:id])
    @book.update_attributes(params[:book])
    respond_with @book
end

这里是best_in_place选择sn-p:

<%= best_in_place @book, :publisher_id, type: :select, collection: Publisher.all.order_by([:name]).map {|x| [x.id, x.name] } %>

出版商:has_many :books,图书:belongs_to 出版商

有人可以帮帮我吗?如果您需要更多信息,我会发布。非常感谢您的帮助!

【问题讨论】:

    标签: ruby-on-rails mongoid best-in-place


    【解决方案1】:

    我解决了这个问题。这是一个验证,禁止我更新。因为当我更新此字段时,无法再访问以发布者名称保存在目录中的已保存文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-02
      • 2021-03-21
      • 2019-01-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多