How to add a dropdown <option> in a rails form? -


i had created scaffold-

rails g scaffold shipment name:string description:text from:string to:string date:string pay:string 

i want form:string drop down (with kolkata/delhi/mumbai options) , not text field. how can this?

i had searched web upper level. new rails , trying learn this.

you can use select helper in app\views\shipments\_form.html.erb file

<%= form_for(@shipment) |f| %>      <%= f.label :from %><br>     <%= f.select :from, [ 'kolkata','delhi','mumbai' ], :prompt => 'select one' %>      <%= f.submit %> <% end %> 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -