lib/seed_dump/perform.rb in seed_dump-0.3.1 vs lib/seed_dump/perform.rb in seed_dump-0.3.2

- old
+ new

@@ -13,11 +13,11 @@ # config @opts['with_id'] = !env["WITH_ID"].nil? @opts['no-data'] = !env['NO_DATA'].nil? @opts['models'] = env['MODELS'] || (env['MODEL'] ? env['MODEL'] : "") @opts['file'] = env['FILE'] || "#{Rails.root}/db/seeds.rb" - @opts['append'] = (!env['APPEND'].nil? && File.exists?(opts['file']) ) + @opts['append'] = (!env['APPEND'].nil? && File.exists?(@opts['file']) ) @ar_options = env['LIMIT'].to_i > 0 ? { :limit => env['LIMIT'].to_i } : {} @indent = " " * (env['INDENT'].nil? ? 2 : env['INDENT'].to_i) @opts['models'] = @opts['models'].split(',').collect {|x| x.underscore.singularize.camelize.constantize } end @@ -39,11 +39,12 @@ def self.dumpModel(model) @id_set_string = '' create_hash = "" rows = [] + arr = [] arr = model.find(:all, @ar_options) unless @opts['no-data'] - arr = arr.empty? ? [model.new] : arr + arr = arr.empty? ? [model.new] : arr arr.each_with_index { |r,i| attr_s = []; r.attributes.each { |k,v| dumpAttribute(attr_s,r,k,v) } if @id_set_string.empty? rows.push "#{@indent}{ " << attr_s.join(', ') << " }"