I built a simple application, which i am trying to update with a form, but got some weirdness going on.
I have a column 'field_items' which is an hStore. If i call debug on the model in my view...
<%= debug @app.field_items %>
I get the two proper items returned. In the rails console i also do not see the three extras.
I have a form_for where i iterate over the 'field_items'
In my form it returns three extra fields "builder", "parent_builder", and "namespace"
Anyone have any ideas? I have noticed if i comment out the serialize line on :field_items in the model, it doesn't return the three extra attributes
Here is my model
class App < ActiveRecord::Base
belongs_to :page
attr_accessible :content, :title, :layouts, :field_items
serialize :layouts, ActiveRecord::Coders::Hstore
serialize :field_items, ActiveRecord::Coders::Hstore
end
Here is the form/code from my edit view
<%= form_for [:admin, @app], :html => { :class => "form app_fields_form" } do |f| -%>
<div id="app_fields_row_container">
<%= f.fields_for :field_items, @app.field_items do |fi| %>
<% @app.field_items.try(:each) do |key, value| %>
<div class='app_fields_row item_row'>
<div class="column col1"><%= text_field_tag key, key, :class => "form_text_field dynamic_attr" %></div>
<div class="column col2"><%= fi.select key, options_for_select(APP_FIELD_TYPES, value), {}, {:class => "form_select"} %></div>
<div class="column col3"><a href="#" class="adm_button h_red small grey app_fields_delete">x</a></div>
</div>
<% end %>
<%- end -%>
</div>
<% end -%>
I was having the same issue. Removing @app.field_items from fields_for worked for me
<%= f.fields_for :field_items do |fi| %>