Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3271660
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:44:59+00:00 2026-05-17T18:44:59+00:00

So suppose I have the Person and Child models: class Person < ActiveRecord::Base has_many

  • 0

So suppose I have the Person and Child models:

class Person < ActiveRecord::Base
    has_many :children
    accepts_nested_attributes_for :children
end

class Child < ActiveRecord::Base
    belongs_to :parent, :class_name => "Person"
    validates_presence_of :name
end

Now when I use a nested form and save a Person with 2 new children, the entire transaction will fail if one of the children fails to validate (i.e. it will rollback).

How do I ignore this validation failure and just save the 1 Person and 1 child that are valid? I do not want the entire transaction to fail because 1 child failed the validation. I simply want to save the valid records…

Help much appreciated, thanks!

P.S. using :reject_if if not an option for me because I need to be able to access the invalid records up until the moment I save it into the database (at which time I want to reject the ones that remain invalid)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:45:00+00:00Added an answer on May 17, 2026 at 6:45 pm

    You could solve it without “accepts_nested_attributes_for :children” and save the single objects in your controller seperately…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a Django model as follows: class Person(models.Model): first_name = models.CharField(max_length=50) last_name
Suppose I have a base class Person and I publicly inherit a class Teacher
Suppose i have a base class person. and i publically inherits a class student
Suppose I have the following 2 entities: @Entity public class Person implements Serializable {
Suppose I have an abstract class Person . There is another class Student which
This should be a fundamental C# question. Suppose I have a Person class which
Suppose i have class Person { public int Id {get;set;} public string Name {get;set;}
Suppose I have a Person class and have the following: Person A = new
Suppose I have this code (pseudocode) class SomeClass { class Person { public static
Suppose I have one class Person ……… public class Person { public string Name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.