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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:14:08+00:00 2026-06-15T23:14:08+00:00

I have the following tables: Users, Default Prices, Clients, Client Prices. What I’d like

  • 0

I have the following tables: Users, Default Prices, Clients, Client Prices. What I’d like is to have the default_prices automatically fill in the client_prices table when a new client is created. It looks like I might be able to use a similar solution to this answer. What I would like to happen is when a new client is created by a user, all of the client_prices for the client are populated by the default_prices table.

class User < ActiveRecord::Base
  attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :stripe_token, :default_prices_attributes
  has_many :default_prices
  has_many :clients
  accepts_nested_attributes_for :default_prices, :allow_destroy => true


class DefaultPrice < ActiveRecord::Base
  attr_accessible :price, :user_id, :visit_type, :id
  belongs_to :user
end


class Client < ActiveRecord::Base
  attr_accessible :active, :address_1, :address_2, :city, :email, :first_name, :last_name, :state, :user_id, :zip, :client_prices_attributes
  belongs_to :user
  has_many :client_prices
  accepts_nested_attributes_for :client_prices_attributes


class ClientPrice < ActiveRecord::Base
  attr_accessible :price, :client_id, :visit_type, :id
  belongs_to :uclient
end
  • 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-06-15T23:14:10+00:00Added an answer on June 15, 2026 at 11:14 pm

    You can add before_create block to copy default price.

    before_create do
      user.default_prices.each do |default_price|
        client_prices.build(default_price.attributes.slice("price", "visit_type"))
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following tables: users +----------+----------+----------+ | id | name | dob |
I have the following tables: Users: userId , userFirstName , userLastName . holdBilling: bEntityID
I have following tables questions -> id, question_data, user_id users -> id, fname, lname
I have the following tables: team_members userid teamid users uid name_f name_l friends friend_id
In my application I have the following tables: Posts id title content Users id
I have the following 3 tables: team_data id team_id team_name team_members userid teamid users
I have 3 tables with the following columns : * users : user_id *
Ok, I have the following Users table: id | name | birthday 1 |
I have a table [Users] with the following columns: INT SmallDateTime Bit Bit [UserId],
I have the following tables: People Users Emails The user's password is stored in

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.