开发者

Rails 3: select helper method default?

I currently have this select helper call:

<%= f.select :开发者_如何学Pythonmacro_process_id, MacroProcess.all.collect { |mp| [mp.name, mp.id]} %>

How can i change this that if :macro_process_id has a value, then the selected element should be equal to that value?

If that makes any sense?

Thanks


Try

<%= f.select :macro_process_id, MacroProcess.all.collect { |mp| [mp.name, mp.id]}, MacroProcess.find(:macro_process_id) %>

The addition that I have made, will make it the default value selected among the other values.

For more info, look here: form-select-helper-in-ruby-on-rails

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜