I have a _form.rhtml with the following partial
Type
<%= select 'account', 'account_type', 'user' %>
How can I add other elements i.e. guest, adminstrator to the list in the
selection box.
Thanks
Reg
I have a _form.rhtml with the following partial
Type
<%= select 'account', 'account_type', 'user' %>
How can I add other elements i.e. guest, adminstrator to the list in the
selection box.
Thanks
Reg
Type
<%= select 'account', 'account_type', 'user' %>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]] %>
should work. But if you had an AccountTypes model the API docs show
you a much more elegant way to achieve it:
glenn wrote:
Type
<%= select 'account', 'account_type', 'user' %>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]] %>should work. But if you had an AccountTypes model the API docs show
you a much more elegant way to achieve it:
ActionView::Helpers::FormOptionsHelper
Thanks,
I finally figured out a way to do it:
Type
<%= select 'account', 'account_type', ( [['user'], ['administrator']] )
%>
Reg
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs