preview for association object
This commit is contained in:
parent
768f907f66
commit
e12701b34b
|
@ -10,7 +10,7 @@ class Preview
|
|||
field :object_class_type
|
||||
|
||||
has_many :preview_files, :autosave => true, :dependent => :destroy
|
||||
|
||||
has_many :preview_associations, :autosave => true, :dependent => :destroy
|
||||
# def object=(params)
|
||||
# save_upload_temp_link(params,"news_bulletin_files_attributes") #unless params[]
|
||||
# self.object_f = params
|
||||
|
@ -96,6 +96,14 @@ class Preview
|
|||
eval("virtual_object.#{file.field_name_for_rebuild} = file.file")
|
||||
end
|
||||
end
|
||||
|
||||
preview_associations.each do |local_object|
|
||||
if local_object.object_in_array
|
||||
eval("virtual_object.#{local_object.field_name_for_rebuild}.build local_object.object")
|
||||
else
|
||||
eval("virtual_object.#{local_object.field_name_for_rebuild} = local_object.object")
|
||||
end
|
||||
end
|
||||
virtual_object
|
||||
end
|
||||
|
||||
|
|
|
@ -204,7 +204,13 @@ class Bulletin
|
|||
self.bulletin["bulletin_files_attributes"].each_with_index do |atr,idx|
|
||||
preview_object.preview_files.build(:file=>self.bulletin["bulletin_files_attributes"][idx.to_s],:field_name_for_rebuild=>'bulletin_files',:file_in_array=>true)
|
||||
end unless self.bulletin["bulletin_files_attributes"].nil?
|
||||
preview_object.object = self.bulletin.except("bulletin_files_attributes")
|
||||
|
||||
self.bulletin["bulletin_links_attributes"].each_with_index do |atr,idx|
|
||||
preview_object.preview_associations.build(:object=>self.bulletin["bulletin_links_attributes"][idx.to_s],:field_name_for_rebuild=>'bulletin_links',:object_in_array=>true)
|
||||
end unless self.bulletin["bulletin_links_attributes"].nil?
|
||||
|
||||
|
||||
preview_object.object = self.bulletin.except("bulletin_files_attributes","bulletin_links_attributes")
|
||||
preview_object
|
||||
end
|
||||
|
||||
|
|
|
@ -246,7 +246,12 @@ class NewsBulletin
|
|||
self.news_bulletin["news_bulletin_files_attributes"].each_with_index do |atr,idx|
|
||||
preview_object.preview_files.build(:file=>self.news_bulletin["news_bulletin_files_attributes"][idx.to_s],:field_name_for_rebuild=>'news_bulletin_files',:file_in_array=>true)
|
||||
end unless self.news_bulletin["news_bulletin_files_attributes"].nil?
|
||||
preview_object.object = self.news_bulletin.except("news_bulletin_files_attributes","image")
|
||||
|
||||
self.news_bulletin["news_bulletin_links_attributes"].each_with_index do |atr,idx|
|
||||
preview_object.preview_associations.build(:object=>self.news_bulletin["news_bulletin_links_attributes"][idx.to_s],:field_name_for_rebuild=>'news_bulletin_links',:object_in_array=>true)
|
||||
end unless self.news_bulletin["news_bulletin_links_attributes"].nil?
|
||||
|
||||
preview_object.object = self.news_bulletin.except("news_bulletin_files_attributes","image","news_bulletin_links_attributes")
|
||||
preview_object
|
||||
end
|
||||
|
||||
|
|
Reference in New Issue