daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def add_multiple_associated_save_callbacks(association_name)
  2.           method_name = "validate_associated_records_for_#{association_name}".to_sym
  3.           define_method(method_name) do
  4.             association = instance_variable_get("@#{association_name}")
  5.             if association.respond_to?(:loaded?)
  6.               if new_record?
  7.                 association
  8.               else
  9.                 association.select { |record| record.new_record? }    # **** this one ****
  10.               end.each do |record|
  11.                 errors.add "#{association_name}" unless record.valid?
  12.               end
  13.             end
  14.           end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top