草庐IT

ruby-on-rails - rails : How to insert a text_field without a form just to test the layout?

coder 2025-06-02 原文

我现在正在为我的应用程序做布局,我想插入一个不执行任何操作的 text.field,只是为了看看它的外观。我该怎么做?

最佳答案

有几种方法可以满足您的需求。

1) 只写静态 HTML

<input type="text" name="dummy" />

2) 使用text_field_tag

<%= text_field_tag "dummy", nil %>

3) 使用 form_for 为虚拟对象构建虚拟表单

<%= form_for SomeModel.new do |f| %>
  <%= f.text_field :column_name %>
<% end %>

关于ruby-on-rails - rails : How to insert a text_field without a form just to test the layout?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7536466/

有关ruby-on-rails - rails : How to insert a text_field without a form just to test the layout?的更多相关文章

随机推荐