Posted almost 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

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Martin Straub
Last edit:
4 months 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