I have a _form.rhtml with the following partial <p><label for="account_type">Type</label><br/> <%= select ''account'', ''account_type'', ''user'' %></p> <!--[eoform:account]--> How can I add other elements i.e. guest, adminstrator to the list in the selection box. Thanks Reg -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
> <p><label for="account_type">Type</label><br/> > <%= select ''account'', ''account_type'', ''user'' %></p> > <!--[eoform:account]--> > > How can I add other elements i.e. guest, adminstrator to the list in the > selection box.<%= select ''account'', ''account_type'', [[''user'',''user], [''guest'',''guest],[''administrator'',''administrator]] %></p> should work. But if you had an AccountTypes model the API docs show you a much more elegant way to achieve it: http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000506 --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
glenn wrote:>> <p><label for="account_type">Type</label><br/> >> <%= select ''account'', ''account_type'', ''user'' %></p> >> <!--[eoform:account]--> >> >> How can I add other elements i.e. guest, adminstrator to the list in the >> selection box. > > <%= select ''account'', ''account_type'', [[''user'',''user], > [''guest'',''guest],[''administrator'',''administrator]] %></p> > > should work. But if you had an AccountTypes model the API docs show > you a much more elegant way to achieve it: > http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000506Thanks, I finally figured out a way to do it: <p><label for="account_type">Type</label><br/> <%= select ''account'', ''account_type'', ( [[''user''], [''administrator'']] ) %></p> <!--[eoform:account]--> but thanks for the showing me this option and for the link. Reg -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---