Posted over 5 years ago. Visible to the public.

all_blank_except for accepts_nested_attributes_for

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

Copy
class Post < ActiveRecord::Base has_many :comments accepts_nested_attributes_for :comments, :reject_if => all_blank_except(:position, :other_nested_attrs) end
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Martin Straub
Last edit:
about 1 year ago
by Thomas Eisenbarth
Attachments:
activerecord_base_reject_if_all_blank_except.rb
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Martin Straub to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more