<commit_before>module Spree
  class Slide < ActiveRecord::Base

    belongs_to :heroable, polymorphic: true
    has_one :image, -> { order(:position) }, as: :viewable, dependent: :destroy, class_name: "Spree::Image"
    accepts_nested_attributes_for :image, reject_if: proc {|attributes| attributes['attachment'].nil? or attributes['id'].nil?}, allow_destroy: true

    before_save :set_sort_order

    default_scope -> { order('sort_order asc') }


    private

      def set_sort_order
        sort_order = heroable.slides.size if sort_order.blank?
      end

  end
end<commit_msg>nested attribute rejection update<commit_after>module Spree
  class Slide < ActiveRecord::Base

    belongs_to :heroable, polymorphic: true
    has_one :image, -> { order(:position) }, as: :viewable, dependent: :destroy, class_name: "Spree::Image"
    accepts_nested_attributes_for :image, reject_if: proc {|attributes| attributes['attachment'].nil? and attributes['id'].nil?}, allow_destroy: true

    before_save :set_sort_order

    default_scope -> { order('sort_order asc') }


    private

      def set_sort_order
        sort_order = heroable.slides.size if sort_order.blank?
      end

  end
end
{'fraction_non_alphanumeric': 0.10951979780960404, 'fraction_numerical': 0.0, 'mean_word_length': 4.2105263157894735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5969767', 'n_tokens_mistral': 373, 'n_tokens_neox': 355, 'n_words': 88}