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

  • Home
  • SEARCH
  • 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 6865287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:01:28+00:00 2026-05-27T03:01:28+00:00

Hello I have a model named Client which has nested models called Receiver and

  • 0

Hello I have a model named Client which has nested models called Receiver and Receipt.Basically a client donate money to a receiver or many receivers, and that gift appear in a receipt.

model/client.rb

class Client < ActiveRecord::Base
  has_many :receivers
  has_many :receipts

  accepts_nested_attributes_for :receivers
  accepts_nested_attributes_for :receipts
end

views/client/_form.html.erb

<%= simple_form_for @client do |f| %>
  <%= f.input :name %>
  <%= f.input :input %>
  <%= f.input :suscribtion_number %>
  <%= simple_fields_for :orders do |o| %>
    <%= o.input :name %>
  <% end %>
  <%= f.button :submit %>
<% end %>

Matter fact how can I dynamically transfer a client “input” to
1- an oder’s “amount”(attribute)
2- and to a receipt’s “amount”(attribute)

  • 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-27T03:01:28+00:00Added an answer on May 27, 2026 at 3:01 am

    You can simply do @receipt.amount = @client.amount. However, the better way to model this would be to have a Donation model with an amount attribute. Then, link clients and receivers to the donation.

    The donation model would probably replace your receipt model. When you need to compute how much a client has donated, simply sum all the associated donation amounts.

    By modeling the donation, you won’t need to worry about keeping multiple copies of the same information (i.e. the donation amount) in sync. Having multiple copies of the same information is a bad idea, generally speaking.

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

Sidebar

Related Questions

Hello i'm working on a blog app and I have a model: class Post(models.Model):
Issue: Hello, I have an edit page which enables the client to update the
Hello I have a user model and a ratings model. Whenever a new user
Hello I have the following error by git-fsck, which cannot be cleaned by git-gc
Hello I have a table on which I have denied SELECT privs to a
I have this model: class blog(models.Model): user = models.ForeignKey(User) mail = models.EmailField(max_length=60, null=False, blank=False)
I have these models: class Projects(models.Model): projectName =models.CharField(max_length = 100,unique=True,db_index=True) projectManager = EmbeddedModelField('Users') class
I have a model class, with a property like this: [Display(Name = Phone, Description=Hello
Hello guys I have a doubt in django templates, I have two models with
I have the following models (simplified): class Location(models.Model): name = models.CharField(max_length=100) is_ok = models.BooleanField()

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.