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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:23:21+00:00 2026-05-25T20:23:21+00:00

I have a collection_select with the following code: <%= collection_select(:address, :id, current_user.addresses, :id, :address1,

  • 0

I have a collection_select with the following code:

    <%= collection_select(:address, :id, current_user.addresses, :id, :address1, options ={:prompt => "Select an address"}, 
        html_options={:onchange => "insert_address_fields()"}) %>

insert_address_fields gets called properly when i select an address in the list, but what i want to do is send all the attributes of of the selected address (first name, last name, address, city, state, etc) to the insert_address_fields function. Something like insert_address_fields(<% address.attributes %>), or, if i have to, list the the attributes individually. Is this possible with the setup i have now without making things overly complicated?

  • 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-25T20:23:22+00:00Added an answer on May 25, 2026 at 8:23 pm

    collection_select generates an <input> with a set of <options> fetched from the column of the table you are setting.

    You can only (and should) send the selected address to insert_address_fields() by doing “insert_address_fields(this.value)”. In this case, this will be the input field of the html.

    The function should take care of fetching the relevant information from the address by accessing the database.

    ¿Why?

    1. Otherwise, you are giving too much responsiblity to the view. The view should not parse information and send it to the function (it should be the other way around!)

    2. If you add a column to the address atributes, you will need to change your view. Adding columns should be transparent to the view of your application

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

Sidebar

Related Questions

I have the following code inside the _forms view. <div class=field> Shop: <%= f.collection_select
I have the following code: var foo = (from data in pivotedData.AsEnumerable() select new
following is the code of my select tag <%= select_tag assignee#{cnt}, options_from_collection_for_select(@arr,tmp=id,name , default_selection),
I have the following code and it works good: var _data = (from qu
I have the following code that returns rows from a database when a form
In rails 3, how to create a Dropdown from hash I have following code
I have the following code: var thing = (from t in things where t.Type
I have the following code in C# Visual Studio 2010. string connectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data
Inside my controller's action I have the following code: public ActionResult GridAction(string id) {
I using jQuery and have the following code, it's a partial and I want

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.