vendor/plugins/ar_fixtures/lib/ar_fixtures.rb
##
# Delete existing data in database and load fresh from file in db/table_name.yml
#
# ERB tags are also possible, as with the rest of Rails fixtures.
Delete existing data in database and load fresh from file in db/table_name.yml
ERB tags are also possible, as with the rest of Rails fixtures.
Delete existing data in database and load fresh from file in db / table_name . yml ERB tags are also possible as with the rest of Rails fixtures .
def load_from_file(path=nil)
      path ||= "db/#{table_name}.yml"
      self.destroy_all
      if connection.respond_to?(:reset_pk_sequence!)
        connection.reset_pk_sequence!(table_name)
      end
      rawdata = File.read(File.expand_path(path, RAILS_ROOT))
      erb_data = ERB.new(rawdata).result
      records = YAML::load( erb_data )
      records.each do |record|
        puts "______________"
        puts record.to_yaml
        puts "______________"
        record_copy = self.new(record.attributes)
        record_copy.id = record.id
        klass_col = record.class.inheritance_column.to_sym
        if record[klass_col]
          record_copy.type = record[klass_col]
        end
        record_copy.save
      end
      if connection.respond_to?(:reset_pk_sequence!)
        connection.reset_pk_sequence!(table_name)
      end
    end
def load_from_file ( path = nil ) path ||= "db/#{table_name}.yml" self . destroy_all if connection . respond_to? ( :reset_pk_sequence! ) connection . reset_pk_sequence! ( table_name ) end rawdata = File . read ( File . expand_path ( path , RAILS_ROOT ) ) erb_data = ERB . new ( rawdata ) . result records = YAML :: load ( erb_data ) records . each do | record | puts "______________" puts record . to_yaml puts "______________" record_copy = self . new ( record . attributes ) record_copy . id = record . id klass_col = record . class . inheritance_column . to_sym if record [ klass_col ] record_copy . type = record [ klass_col ] end record_copy . save end if connection . respond_to? ( :reset_pk_sequence! ) connection . reset_pk_sequence! ( table_name ) end end
Delete existing data in database and load fresh from file in db/table_name.yml
ERB tags are also possible, as with the rest of Rails fixtures.
Delete existing data in database and load fresh from file in db / table_name . yml ERB tags are also possible as with the rest of Rails fixtures .
# For Single Table Inheritance
path
<not_specific>