How to create a form in Rails without using form_for and model instance?

First of all, I am new to Rails. I can keep myself in Ruby, but Rails is a completely different story for me. I like the development speed that Rails offers me, but I can’t put up with the existing documentation.

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

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

From the articles I read on the Internet, I realized that this was the case with Rails <2.0. Anyway, in Rails> 2.0, or something equivalent to it? Can you post a snippet?

+16
ruby ruby-on-rails forms
Apr 29 '09 at 21:14
source share
1 answer

Take a look at form_tag .

 <% form_tag '/posts' do %> <div><%= submit_tag 'Save' %></div> <% end %> 
+22
Apr 29 '09 at 21:18
source share



All Articles