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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:26:21+00:00 2026-05-24T01:26:21+00:00

When I submit a text field into user_items I want it to take the

  • 0

When I submit a text field into user_items I want it to take the ID of that item from master_list_items and place it into the master_list_items_id column under user_items

I have added master_list_items.rb — but I’m not sure of the relationship to add..

Any suggestions?

master_list_items

+----------------------+----+
| name                 | id |
+----------------------+----+       
| Item A               | 1  |
| Item B               | 2  |
| Item C               | 3  |
+----------------------+----+  

user_items

+---- +----------+----------------------+
| uid | item     | master_list_item_id  |
+-----+----------+----------------------+
| 2   | Item A   | NULL                 |
| 7   | Item C   | NULL                 |
| 9   | Item C   | NULL                 |
+-----+----------+----------------------+  
  • 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-24T01:26:22+00:00Added an answer on May 24, 2026 at 1:26 am

    I’m going to guess your models are done like this:

    class MasterListItem < ActiveRecord::Base
        has_many :user_items
    end
    
    class UserItem < ActiveRecord::Base
        belongs_to :master_list_item
    end
    

    To implement what you’re looking for the solution would probably be like this:

    master_list_item = MasterListItem.create( :name => "Item 1" )
    user_item = master_list_item.user_items.build( :name => "User Item 1" )
    user_item.save
    

    This should yield the results you’re looking for.

    For more on relationships refer to the associations module on ActiveRecord.

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

Sidebar

Related Questions

I want a simple form with one text box and a submit button. For
Hi I have a field that uses ajax to bring up product/item information <input
I want to run a background task that reads input from a TextReader and
I have 2 text boxes and a submit button.On clicking on the submit button
I have a form with a text area input. I'm using JQuery to submit
I submit an update to UpdateListItems. It returns success but the list item ahs
Is it acceptable to submit from an http form through https? It seems like
I have a submit button that is a block of HTML code because of
Currently I have an HTML form with a hidden field right before a text
I am trying a servlet that puts the data into the database:derbi (that comes

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.