Wednesday, 15 February 2012

Not selecting my roles? - Rails 4.2, Multi Select box -


I have an editing form, where you can choose several roles for a particular group. It seems that it does in the context of popularizing your selection box and saving the case in choosing the database.

But when it comes to editing, while it populates correctly, it does not already select selected roles. The relationship between groups and roles is as follows:

  is_maya: roles ,: through = = : Groups_rolls in groups of groups  

My selection box is set for both edit and new ideas:

  & Lt; Div class = "form-group" & gt; & Lt; Label class = "col-sm-4 control-label" & gt; Select roles for this group & lt; / Label & gt; & Lt; Div class = "col-sm-6" & gt; & Lt;% = f.select (: roles, options_for_select (Xaaron :: Role.pluck (: role_name) ,: selected = & gt; @ group.roles), {}, category: 'form-control', multiple: True) & gt%; & Lt; / Div & gt; & Lt; / Div & gt;  

So what's the deal? Like I said, it populates, lets you choose, it saves you the chosen work. But does not select the already selected roles for this group.

Post-text "itemprop =" text ">

selected is the argument, not a hash option as you had announced. See the specification for.


No comments:

Post a Comment