[英]Rails: How to insert a text_field without a form just to test the layout?
I am just doing the layout for my app at the moment and I want to insert a text.field that does nothing just to see how it looks. 我现在正在为我的应用程序做布局,我想插入一个text.field,它只是为了看它的外观。 How can I do this?
我怎样才能做到这一点?
There are a few ways that could do what you want. 有几种方法可以做你想要的。
1) just write the static HTML 1)只写静态HTML
<input type="text" name="dummy" />
2) Using text_field_tag
2)使用
text_field_tag
<%= text_field_tag "dummy", nil %>
3) Building a dummy form using a form_for for a dummy object 3)使用form_for为虚拟对象构建虚拟表单
<%= form_for SomeModel.new do |f| %>
<%= f.text_field :column_name %>
<% end %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.