In my Users model I have serialize :roles Letting it default to yml I enter roles as a text array. e.g., u.roles = ["member","scorer"] It displays as an array @user.roles.type returns Array All is fine except if I try to use the select form helper to input the values with multiple => true I''ve tried several version and I can''t get the set values to trigger selected in the options tag. f.select(:roles, options_for_select(role_options,@user.roles),{}, {:multiple => true, :size => 5}) f.select(:roles, role_options,{},{:multiple => true, :size => 5}) (role_options is a helper method that return an array of valid role options. I had this working under 3.0, but using a kludge to put roles into a json hash. Steve -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Happens every time - I find the problem after the post. In the rails 3.0 version I capitalized the roles. In the rails 3.1 version I lower cased the roles. One of the few things I hate about ruby/rails case sensitivity. On Aug 18, 9:05 am, AppleII717 <sa...-ee4meeAH724@public.gmane.org> wrote:> In my Users model I have > > serialize :roles > > Letting it default to yml > > I enter roles as a text array. e.g., > u.roles = ["member","scorer"] > > It displays as an array > > @user.roles.type returns Array > > All is fine except if I try to use the select form helper to input the > values with multiple => true > > I''ve tried several version and I can''t get the set values to trigger > selected in the options tag. > > f.select(:roles, options_for_select(role_options,@user.roles),{}, > {:multiple => true, :size => 5}) > f.select(:roles, role_options,{},{:multiple => true, :size => 5}) > > (role_options is a helper method that return an array of valid role > options. > > I had this working under 3.0, but using a kludge to put roles into a > json hash. > > Steve-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2011-Aug-18 14:28 UTC
Re: Re: rails 3.1 select multiple with serialized data
Add a before_save filter and downcase/upcase/titleize them for uniformity! Walter On Aug 18, 2011, at 10:22 AM, AppleII717 wrote:> Happens every time - I find the problem after the post. > > In the rails 3.0 version I capitalized the roles. > In the rails 3.1 version I lower cased the roles. > > One of the few things I hate about ruby/rails case sensitivity. > > > On Aug 18, 9:05 am, AppleII717 <sa...-ee4meeAH724@public.gmane.org> wrote: >> In my Users model I have >> >> serialize :roles >> >> Letting it default to yml >> >> I enter roles as a text array. e.g., >> u.roles = ["member","scorer"] >> >> It displays as an array >> >> @user.roles.type returns Array >> >> All is fine except if I try to use the select form helper to input >> the >> values with multiple => true >> >> I''ve tried several version and I can''t get the set values to trigger >> selected in the options tag. >> >> f.select(:roles, options_for_select(role_options,@user.roles),{}, >> {:multiple => true, :size => 5}) >> f.select(:roles, role_options,{},{:multiple => true, :size => 5}) >> >> (role_options is a helper method that return an array of valid role >> options. >> >> I had this working under 3.0, but using a kludge to put roles into a >> json hash. >> >> Steve > > -- > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails- > talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > . >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.