lib/seed-fu/seeder.rb in seed-fu-2.2.0 vs lib/seed-fu/seeder.rb in seed-fu-2.3.0

- old
+ new

@@ -62,10 +62,16 @@ record = find_or_initialize_record(data) return if @options[:insert_only] && !record.new_record? puts " - #{@model_class} #{data.inspect}" unless @options[:quiet] - record.assign_attributes(data, :without_protection => true) + # Rails 3 or Rails 4 + rails/protected_attributes + if record.class.respond_to?(:protected_attributes) && record.class.respond_to?(:accessible_attributes) + record.assign_attributes(data, :without_protection => true) + # Rails 4 without rails/protected_attributes + else + record.assign_attributes(data) + end record.save(:validate => false) || raise(ActiveRecord::RecordNotSaved) record end def find_or_initialize_record(data)