如何在Rails中创建表单而不必使用form_for和模型实例? [英] How can I create a form in Rails without having to use form_for and a model instance?

查看:71
本文介绍了如何在Rails中创建表单而不必使用form_for和模型实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我是Rails的新手.我可以使用Ruby拥有自己的东西,但是Rails对我来说是一个完全不同的故事.我喜欢Rails为我提供的开发速度,但似乎无法与现有文档融洽相处.

First of all, I'm a Rails newbie. I can hold my own in Ruby, but Rails is a whole different story for me. I like the development speed Rails offers me, but I can't seem to make peace with the existing documentation.

到目前为止,对于我所有的表格,我都使用了 form_for ,以及一个我需要创建的模型的实例(例如,提交一本新书).我真的很想能够写像这样的东西:

For all of my forms so far, I used form_for, with an instance for the model I needed to create ( for example, submitting a new book ). I would really like to be able to just write something like :


<% form(:action => "whatever") %>
  <% text_field ... %>
  <% file_field ... %>
<% end %>

从我在网上阅读的文章中,我了解到这是Rails中完成事情的方式< 2.0.无论如何,在Rails>中执行此操作2.0或等同的东西?你能发个摘要吗?

From the articles I read online, I understood that this was the way things got done in Rails < 2.0 . Is there anyway of doing this in Rails > 2.0, or something equivalent to it ? Can you please post a snippet ?

推荐答案

看看 查看全文

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