0

我正在使用Rails 4.0.0Mongoid 和 HAML 我有以下模型结构:

class Merchant
  has_one :setting
end

class Setting
  belongs_to :merchant
  has_many :categories
end

class Category
  belongs_to :setting
end

Setting被有意地布置为单一资源。所以我有这些路线:

resources :merchants do
  resource :setting, only: [:show, :edit, :update] do
    resources :categories
  end
end

当我使用标准表单助手为如下类别创建表单时:

= form_for([@merchant, @setting, @category])  do |f|

我编辑了一个类别,我得到以下 HTML:

<form accept-charset="UTF-8" action="/merchants/5257cfdf16abe9985c000002/setting/categories/5257cfdf16abe9985c000003" class="edit_category" id="edit_category_525c090a16abe9988f000001" method="post">

这是错误的。category_id应该525c090a16abe9988f000001与 form_tag 的属性中的一样id,但不是。

当涉及到单一资源时,我遇到了所有 polymorphic_path 助手的类似奇怪行为。我敢肯定,我在这里做错了什么。或者 Rails 4 中的 path_helpers 和 polymorphic_path 助手有问题吗?

4

0 回答 0