semantic_form_for (and semantic_fields_for) does this:
@@builder.custom_namespace = options.delete(:namespace).to_s
custom_namespace is generated via class_attribute, which does does the following "fun" things:
activesupport (3.2.9) lib/active_support/core_ext/module/remove_method.rb:4:in `remove_possible_method'
activesupport (3.2.9) lib/active_support/core_ext/class/attribute.rb:111:in `custom_namespace='
activesupport (3.2.9) lib/active_support/core_ext/class/attribute.rb:110:in `custom_namespace='
formtastic (2.2.1) lib/formtastic/helpers/form_helper.rb:147:in `semantic_form_for'
it removes and generates several new methods every time semantic_form_for is called, this invalidates ruby's method caches and can lead to races under multithreading.
Easy to reproduce on the rails console the following way:
> helper.semantic_form_for :foo
@the8472 any suggestions on what changes to make? A pull request would be great!
We have to use a mutex if we want to keep the usage of class variable.
But I suggest to move that to an instance variable instead of a class variable, it's less problematic.
I don't know why it even is a class variable. If the namespace is only supposed to cascade to child form builders they could easily pass it down during construction. So yes, an instance variable would seem to be the cleanest solution.
@the8472 can you make a pull request changing it to instance variable?