如何为 Rails SimpleForm 选择框设置默认选定值 [英] How to set default selected value for Rails SimpleForm select box

查看:31
本文介绍了如何为 Rails SimpleForm 选择框设置默认选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何设置由 SimpleForm 生成的选择框的选定选项.我的代码是这样的:

I'm trying to figure out how to set the selected option of a select box generated by SimpleForm. My code is along the lines of:

<%= simple_form_for(@user) do |f| %>
  <%= f.association :store, default: 1 %>

当然 default: 1 部分不起作用.

Of course the default: 1 part does not work.

TIA

推荐答案

使用以下内容:

selected: 1

这篇关于如何为 Rails SimpleForm 选择框设置默认选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆