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

The Archive Base Latest Questions

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

Two models: category has_many: components component belongs_to: category The CATEGORY table defines variable names

  • 0

Two models:

category has_many: components
component belongs_to: category

The CATEGORY table defines variable names for different component types:

TYPE, VAR1, VAR2, VAR3, ...

Insulator, Voltage, Height, Material, ...

Current Transformer, Voltage, Ratio, Indoor, ...

In the NEW/EDIT views for the COMPONENT model, the user will first section the CATEGORY from a drop-down list. Based on the CATEGORY selected the column headings and field labels in the form(s) need to dynamically update to indicate the variable names associated with the selected CATEGORY.

i.e. IF the user selects CATEGORY = Insulator THEN the field labels for VAR1 … VAR3 are Voltage, Height, Material, etc.

I assume this will be controlled in the _form.html.erb of a typical scaffold. I am looking for a recommended technique.

Thanks in advance any information.

  • 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-24T04:26:57+00:00Added an answer on May 24, 2026 at 4:26 am

    Changing a form in response to a user selecting a different option in a select tag is probably best done by Javascript. This allows for execution on the client side, which will be faster than a trip back to the server.

    I would recommend placing the different form fields inside a div tag that is hidden when the page loads. Each of the combinations of categories can be toggled to show in the form by binding to the Javscript onChange event on the select tag.

    Here is more information on the select tag: http://www.w3schools.com/jsref/event_onchange.asp

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

Sidebar

Related Questions

I have two models, 'product' with 'belongs_to' and 'category' with 'has_many'. Product has a
i have two models: class Category has many :jobs end class Job belongs_to :category
I have two models: store and category with a joining table called categories.stores .
I have two models as follows: icon.rb belongs_to :category attr_accessible :name, :url, :category_id, :icon_for
I have two model Product and Category, they have has_many, and belongs_to association respectively.
I have two models, Category and Point . The associations are defined as: Category
I've got two models, joined by a Has and Belongs To Many join table.
I have two models, Project and Category, which have a many-to-many relationship between them.
I have a two models: class Category(models.Model): pass class Item(models.Model): cat = models.ForeignKey(Category) I
Let's say you have two models: Post and Category . Each Post has a

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.