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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:01:02+00:00 2026-05-26T18:01:02+00:00

I am implementing in Ruby on Rails and I am trying to work with

  • 0

I am implementing in Ruby on Rails and I am trying to work with the collection_select, I’m a newbie. I just want to do, I have a list with groups and a list with roles. These are both models. So, I list my groups, and next to that, I have a dropdown list with the role for the group. each group has 1 role.
I implemented some code already, but the collection_select always only remembers the last item. So I want a list with groups, connected with the desired role. But, now I only have 1 item. This is my view:

<% @groups.each do |group| %>
      <li>      
       <%= collection_select('group', 'role_id', @roles, 'id', 'name') %>
      </li>
<% end %>

I don’t really know what to do now? Someone who knows what I am doing wrong?

Thanks

  • 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-26T18:01:03+00:00Added an answer on May 26, 2026 at 6:01 pm

    So, I assume that you’re doing a form? What model does the form belong to?

    To help debug this sort of thing, usually it’d be a good idea to check your development.log file to see what parameters the form is passing to the controller. Something like:

    Parameters: {"commit"=>"Save", "action"=>"update", "_method"=>"put", 
        "id"=>"6168", "group"=>{"role_id"=>"2", ...}, "controller"=>"groups"}
    

    Now, usually a Rails controller is expecting a form with the data for a single model. If you’re wanting to update multiple models or rows at the same time, you’re going to have to get creative.

    First thing to do might be to try returning an array of groups. Your form at the moment is not using an array. I doubt that these Rails helpers will help you though. Helpers like these are designed to update one ActiveRecord object at once.

    It’s possible you may need to rethink the design of your app to better fit the Rails way, or roll your own form and iterate over the array that it passes through. Doing it the Rails way is the recommended option, it just might take some brain bending from your end to figure that part out. If you need help, maybe provide more information on what you’re actually trying to achieve.

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

Sidebar

Related Questions

I have built a blog using Ruby on Rails. New to both. I am
I am implementing in Ruby on Rails, and i want to do so, that
I am implementing in Ruby on Rails, and i have 2 views. In my
I am implementing in Ruby on Rails, and I have a view, with all
I am implementing in Ruby, and I just want to read in a CSV-file.
I am implementing the following problem in ruby. Here's the pattern that I want
I'm implementing an application in ruby on rails (although this is a minor detail)
i am implementing a few weeks now in Ruby. And what i want to
I'm implementing a rudimentary version of LISP in Ruby just in order to familiarize
Using Ruby on Rails 3: I semi-understand how accepts_nested_attributes_for is supposed to work, but

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.