move saves into baes class
This commit is contained in:
parent
a0b58fdc2f
commit
fc611ce5c4
@ -43,17 +43,6 @@ module Merged
|
||||
section.reset_index if reindex
|
||||
end
|
||||
|
||||
def save
|
||||
super
|
||||
Card.save_all
|
||||
end
|
||||
|
||||
def self.save_all
|
||||
data = Card.the_private_records.collect {|obj| obj.attributes}
|
||||
File.write( Card.full_path , data.to_yaml)
|
||||
Card.reload
|
||||
end
|
||||
|
||||
def self.new_card(card_template , section_id , index)
|
||||
data = { section_id: section_id , index: index}
|
||||
template = CardStyle.find_by_template( card_template )
|
||||
|
@ -52,17 +52,6 @@ module Merged
|
||||
Image.delete( self.id )
|
||||
end
|
||||
|
||||
def save
|
||||
super
|
||||
Image.save_all
|
||||
end
|
||||
|
||||
def self.save_all
|
||||
data = Image.the_private_records.collect {|obj| obj.attributes}
|
||||
File.write( Image.full_path , data.to_yaml)
|
||||
Image.reload
|
||||
end
|
||||
|
||||
def asset_name
|
||||
image_root + "/" + self.id.to_s + "." + self.type
|
||||
end
|
||||
|
@ -66,7 +66,6 @@ module Merged
|
||||
self.redirects = olds.join(" ")
|
||||
updated_at = Time.now
|
||||
super
|
||||
Page.save_all
|
||||
end
|
||||
|
||||
def self.new_page(name )
|
||||
@ -80,10 +79,5 @@ module Merged
|
||||
nil
|
||||
end
|
||||
|
||||
def self.save_all
|
||||
data = Page.the_private_records.collect {|obj| obj.attributes}
|
||||
File.write( Page.full_path , data.to_yaml)
|
||||
Page.reload
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -77,11 +77,6 @@ module Merged
|
||||
has_cards
|
||||
end
|
||||
|
||||
def save
|
||||
super
|
||||
Section.save_all
|
||||
end
|
||||
|
||||
def self.new_section(template , page_id , index)
|
||||
data = { template: template , index: index , page_id: page_id}
|
||||
style = SectionStyle.find_by_template( template)
|
||||
@ -97,11 +92,5 @@ module Merged
|
||||
s
|
||||
end
|
||||
|
||||
def self.save_all
|
||||
data = Section.the_private_records.collect {|obj| obj.attributes}
|
||||
File.write( Section.full_path , data.to_yaml)
|
||||
Section.reload
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -1,8 +1,19 @@
|
||||
require "active_hash"
|
||||
|
||||
module ActiveHash
|
||||
module ActiveYaml
|
||||
Base.class_eval do
|
||||
|
||||
def save
|
||||
super
|
||||
self.class.save_all
|
||||
end
|
||||
|
||||
def self.save_all
|
||||
data = @records.collect {|obj| obj.attributes}
|
||||
File.write( self.full_path , data.to_yaml)
|
||||
self.reload
|
||||
end
|
||||
|
||||
def self.delete(id) # only works with id's
|
||||
@record_index.delete(id.to_s)
|
||||
@records.delete_if{|record| record[:id] == id.to_i}
|
||||
|
Loading…
Reference in New Issue
Block a user