Ruby on rails 3 Formtastic:在输入字段中插入预加载的文本

Ruby on rails 3 Formtastic:在输入字段中插入预加载的文本,ruby-on-rails-3,forms,formtastic,Ruby On Rails 3,Forms,Formtastic,如何在Formtastic的经典输入字段中添加预加载的costant字符串 我已经搜索了很多,但我还没有找到如何解决这个问题 例如,我的表格中有一行代码: <%= f.input :url, :hint => "Url in the form of: http//www.mysite.com" %> “Url格式为:http//www.mysite.com”%> 在输入字段中,我想预加载:“http://”,因此用户必须只填写URL的剩余部分 这应该是你想要的 <%

如何在Formtastic的经典输入字段中添加预加载的costant字符串

我已经搜索了很多,但我还没有找到如何解决这个问题

例如,我的表格中有一行代码:

<%= f.input :url, :hint => "Url in the form of: http//www.mysite.com"  %>
“Url格式为:http//www.mysite.com”%>

在输入字段中,我想预加载:“http://”,因此用户必须只填写URL的剩余部分

这应该是你想要的

<%= f.input :url, :hint => "Url in the form of: http//www.mysite.com", :input_html => { :value => "http://" }%>
“Url格式为:http//www.mysite.com”,:input_html=>{:value=>“http://”}%>

根据您的提示,我找到了正确的解决方案,当您接受我所做的编辑时,我将接受您的答案:)这种方法的问题在于它会覆盖任何现有值。例如,如果表单已提交,但返回一些验证错误。用户的输入将被“http://”覆盖。