开发者

How can i add elements into drop down list in rails?

I want to add drop down list with my own values. According to the given drop down list value i am going to do a search开发者_Go百科 particular data. My drop down list should be contained trainer, venue, name and date.

I am working on ruby 1.9.2 and rails 2.3.8 versions and postgresql database adapter. I do not need to retrieve data from database. Drop down list should be contained with my given vales. How can i do this? Anybody plz help me....


You can simply add element as follows

Hear I assume there is a model call Entry and it contain two field call :name and :temperature. So I give this example to illustrate drop down menu for select temperature. It may have three values (Hot,Medium,Cold) and this is how we have to write the code

<% form_for @entry do |f| %>
  <%= f.text_field :name %>
  <%= f.select :temperature, [['Hot','hot'],['Medium','medium'],['Cold','cold']] %>
  <%= f.submit %>
<% end %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜