Reputation: 293
I had created a scaffold-
rails g scaffold shipment name:string description:text from:string to:string date:string pay:string
I want the form:string
to be a drop down (with Kolkata/Delhi/Mumbai as options) and not a text field. How can I do this?
I had searched the web but everything was too upper level. I am new to Rails and am trying to learn this.
Upvotes: 1
Views: 6291
Reputation: 1267
you can use the select helper in your app\views\shipments\_form.html.erb
file
<%= form_for(@shipment) do |f| %>
<%= f.label :from %><br>
<%= f.select :from, [ 'Kolkata','Delhi','Mumbai' ], :prompt => 'Select One' %>
<%= f.submit %>
<% end %>
Upvotes: 4