English 中文(简体)
收集——选择总是只有一个项目,而不是一个阵列? 铁路上的废墟
原标题:Collection_select has always only 1 item, not an array? In ruby on rails

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 %>

我不知道现在要做什么? 有些人知道我做了什么错误?

增 编

最佳回答

因此,我假定你重新采取某种形式? 形式属于什么模式?

帮助阻止这种事情,通常是检查你们发展的良好想法。 记录显示,该表将哪些参数转给控制员。 类似:

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

现在,通常一名铁路控制员正在期待一种表格,其中附有单一模型的数据。 如果你再次希望同时更新多种模式或行文,你就会重新获得创造性。

首先要做的是试图遣返一系列团体。 你目前的形式不是使用阵列。 我怀疑这些铁路帮助者会帮助你。 这些帮助者旨在一劳永逸地更新一个积极核查物体。

可能的话,您可能需要重新思考如何设计你的 app,以更好地适应铁路轨道,或者将自己的形式推向通过的各个阵列。 铁路运输方式是所建议的选择,从您的结尾就算出一部分。 如果你需要帮助,也许会提供更多信息,说明你实际上想要达到什么目标。

问题回答

暂无回答




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签