0

I am using Rails 4.0.0 with Mongoid and HAML I have the following model structure:

class Merchant
  has_one :setting
end

class Setting
  belongs_to :merchant
  has_many :categories
end

class Category
  belongs_to :setting
end

Setting is layed out as singular resource by intention. So I have these routes:

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

When I make use of the standard form helpers to create a form for categories like so:

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

and I edit a category, I get the following HTML:

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

which is wrong. The category_id should be 525c090a16abe9988f000001 as in the form_tag's id attribute, but is not.

I encounter a similarily strange behaviour with all polymorphic_path helpers when it comes to singular resources. I am sure, I'm doing something wrong here. Or is there a problem with path_helpers and polymorphic_path helpers in Rails 4?

GeorgieF
  • 2,687
  • 5
  • 29
  • 43
  • is the id the one of `@setting` ? i don't think that rails is inventing UUIDs here – phoet Nov 03 '13 at 18:54
  • The ID's format comes from MongoDB/Mongoid. The path_helpers seem not to get along with singular resources at all. The deeper the nesting, the more they mix up the ID's of the resources, cause they seem to be wanting to include ID's of singular resources as well. IMHO a mayor bug. – GeorgieF Nov 06 '13 at 12:33

0 Answers0