我在创建没有方法关联的text_field时遇到问题.也许我甚至不需要它:-)
我有两个与同一方法关联的radio_buttons:
<%= radio_button :comment, :author, "anonymous" %> Anonymous <br>
<%= radio_button :comment, :author, "real_name" %> Name <br>
Run Code Online (Sandbox Code Playgroud)
我想做的是有一个text_field,当用户点击radio_button"real_name"时,我可以验证这个新text_field中的值.
基本上我的控制器将是这样的:
@comment = Comment.new(params [:comment])
if @ comment.author =="real_name"@ comment.author ="value-from-the-text-end end
有办法吗?
问候,
胜利者
| 归档时间: |
|
| 查看次数: |
2548 次 |
| 最近记录: |