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 4272552
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:35:34+00:00 2026-05-21T07:35:34+00:00

Im using Rails 3.0.3 I have a Model Bill: class Bill < ActiveRecord::Base has_many

  • 0

Im using Rails 3.0.3
I have a Model Bill:

class Bill < ActiveRecord::Base
   has_many :entries    
   accepts_nested_attributes_for :entries

end

In my Bill view i am using nested forms to create new entries in bills and with Javascript i insert existing entries with at this point, have no bill_id:

$("#row" + nested_form_id).append("<input type='hidden' name='bill[entries_attributes][" + nested_form_id + "][id]' id='bill_entries_attributes_" + nested_form_id + "_id' value='" + id +"' >");

when i submit the form i get this error:

ActiveRecord::RecordNotFound (Couldn't find Entry with ID=127 for Bill with ID=):
  app/controllers/bills_controller.rb:121:in `new'
  app/controllers/bills_controller.rb:121:in `create'

so the problem is, that rails is looking for the entry in bills when i submit

any idea how i can fix this?

  • 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-21T07:35:35+00:00Added an answer on May 21, 2026 at 7:35 am

    I couldnt figure out how this is possible with nested forms, so i set the entries which allready exists manually to the bill:

    nested_entries = {}      
    params[:bill][:entries_attributes] = {}  
    
    
    params[:entries].each_pair do |key, value|    
       if value[:id].nil?
          params[:bill][:entries_attributes][key] = value 
       else 
         nested_entries[key] = value
       end                             
    end           
    
    @bill = Bill.new(params[:bill])  
    @bill.save  
    
    bill_id = @bill.id        
    
    nested_entries.each_pair do |key, value|   
       @entry = Entry.find(value[:id])    
       value[:bill_id] = bill_id                            
       @entry.update_attributes(value) 
    end 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Rails 3. I have 3 models: class Deal < ActiveRecord::Base has_many :wishes,
I am using Rails 3 and here is my model class LineItem < ActiveRecord::Base
Using: Rails 3.1.1 I have a controller/model/view called Category that is built up on
I using the Rails resource_controller plugin. I have a ReleasesController, which is nested within
I'm using Rails' accepts_nested_attributes_for method with great success, but how can I have it
I'm using Rails 3.0 and the acts_as_taggable_on gem. I have a Candy model and
I'm using rails 3, and began my application with ActiveRecord. Now, I have many
Note: I'm using Rails 2.3.8, not 3. I have a Photo model with a
Im using Rails 2.3.5 and I have a model, let's call it Post. I
I have a naked rails 3 app with one model, generated using rails g

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.