Sha256: 39f0ce4dd818c2de7510a5811c2effba89cb2eb59cf4d245d5dbb194322d2c60
Contents?: true
Size: 1.23 KB
Versions: 36
Compression:
Stored size: 1.23 KB
Contents
class InitialData extend Cms::DataLoader #Fixture-like way of creating initial data, except that it actually calls the real model methods #This way things like acts_as_list and versioning get setup properly for these records #The syntax is that you call create_whatever(:something, ...), where whatever is the model name, #something is the identifier you give this record, and the ... is the hash of options to pass #to the model constructor. By calling the create_ method, you can then refer to the record later #in the same way you would with fixtures, by saying whatevers(:something) def self.load_demo eval open("#{Rails.root}/db/demo/data.rb"){|f| f.read} Dir["#{Rails.root}/db/demo/page_partials/*.erb"].map do |f| name, format, handler = File.basename(f).split('.') create_page_partial(name.to_sym, :name => name, :format => format, :handler => handler, :body => open(f){|f| f.read}) end Dir["#{Rails.root}/db/demo/page_templates/*.erb"].map do |f| name, format, handler = File.basename(f).split('.') create_page_template(name.to_sym, :name => name, :format => format, :handler => handler, :body => open(f){|f| f.read}) end end end
Version data entries
36 entries across 36 versions & 11 rubygems