solve a bug on has_ony / has_many caused by the caching mechanism

This commit is contained in:
did 2011-05-21 01:02:03 +02:00
parent 7f9a62b0f4
commit 8f36f5a2d8
3 changed files with 12 additions and 0 deletions

View File

@ -53,6 +53,14 @@ class ContentInstance
Hash.new.replace(self.errors)
end
def reload_parent!
self.class.reload_parent!
end
def self.reload_parent!
self._parent = self._parent.reload
end
def to_liquid
Locomotive::Liquid::Drops::Content.new(self)
end

View File

@ -1,3 +1,5 @@
- field.target.constantize.reload_parent! # to make sure all the contents from the parent are loaded
= form.custom_input field._alias.to_sym, :label => field.label, :hint => field.hint, :css => 'has-many' do
.has-many-selector

View File

@ -1,2 +1,4 @@
- field.target.constantize.reload_parent! # to make sure all the contents from the parent are loaded
= form.input field._alias.to_sym, :label => field.label, :hint => field.hint, :input_html => { :class => 'has_one' }, :as => :select, :collection => options_for_has_one(field), :selected => form.object.send(field._alias.to_sym).try(:_id)