all_blank_except for accepts_nested_attributes_for

Posted About 10 years ago. Visible to the public.

Put the attached file to config/initalizers to ignore some fields for rejecting nested records (e.g. hidden input fields).

class Post < ActiveRecord::Base
  
  has_many :comments
  accepts_nested_attributes_for :comments, :reject_if => all_blank_except(:position, :other_nested_attrs)

end
Last edit
Almost 9 years ago
License
Source code in this card is licensed under the MIT License.
Posted to makandra dev (2014-03-19 14:11)