# Inserting data using form\_for

**URL:** <https://www.ruby-forum.com/t/inserting-data-using-form-for/127027>\
**Category:** Rails\
**Created:** [January 24, 2008, 10:26am UTC](https://www.ruby-forum.com/t/inserting-data-using-form-for/127027 "2008-01-24T10:26:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [January 24, 2008, 10:26am UTC](https://www.ruby-forum.com/t/inserting-data-using-form-for/127027/1 "2008-01-24T10:26:41Z")

</div>

I was playing around with:  
[http://strawr.googlecode.com/svn/trunk/app/views/feeds/show.rhtml](http://strawr.googlecode.com/svn/trunk/app/views/feeds/show.rhtml)

and changed a few things so that it’s like so:

thufir@arrakis ~/strawr $  
thufir@arrakis ~/strawr $ cat app/views/feeds/show.rhtml -n | head -n 47  
| tail -n 10  
38  
39 \<% @unused\_tags = Tag.find(:all) - @feed.tags %\>  
40 \<% if @unused\_tags.any? %\>  
41 \<% form\_for :tag, @tag, :url =\> { :action =\> “create” } do |  
f| %\>  
42 \<%= f.text\_field :tag %\>  
43 \<%= submit\_tag ‘Create’ %\>  
44 \<% end %\>  
45 \<% end %\>  
46  
47  
thufir@arrakis ~/strawr $

However, what does the above actually _do_? Here’s output from “script/  
server mongrel”:

Processing FeedsController#create (for 127.0.0.1 at 2008-01-24 01:16:37)  
[POST]  
Session ID: 98ae0df6837d8c491cfd58ecfee7c744  
Parameters: {“commit”=\>“Create”, “tag”=\>{“tag”=\>“is this a tag or  
feed? should be tag…”}, “action”=\>“create”, “controller”=\>“feeds”}  
Feed Columns (0.012260) SHOW FIELDS FROM feeds  
SQL (0.008202) BEGIN  
SQL (0.012374) INSERT INTO feeds (`feed`) VALUES(NULL)  
SQL (0.027005) COMMIT  
Redirected to [http://localhost:3000/feeds/list](http://localhost:3000/feeds/list)  
Completed in 0.08288 (12 reqs/sec) | DB: 0.05984 (72%) | 302 Found  
[[http://localhost/feeds/create](http://localhost/feeds/create)]

Processing FeedsController#list (for 127.0.0.1 at 2008-01-24 01:16:38)  
[GET]  
Session ID: 98ae0df6837d8c491cfd58ecfee7c744  
Parameters: {“action”=\>“list”, “controller”=\>“feeds”}  
Feed Columns (0.007587) SHOW FIELDS FROM feeds  
SQL (0.000587) SELECT count(\*) AS count\_all FROM feeds  
Feed Load (0.000567) SELECT \* FROM feeds LIMIT 0, 10  
Rendering within layouts/feeds  
Rendering feeds/list  
Completed in 0.04696 (21 reqs/sec) | Rendering: 0.01785 (38%) | DB:  
0.00874 (18%) | 200 OK [[http://localhost/feeds/list](http://localhost/feeds/list)]  
\*\* INT signal received.  
Exiting  
thufir@arrakis ~/strawr $

where it loks to be inserting a null value into the feeds table, yes?

This is interesting, as it’s close to what I want, which would be  
inserting data into tags and _also_ the join table, memberships.

However, it’s inserting data, which is progress 🙂

So, I haven’t commited this to the svn repository (I need to practice  
branching for stuff like this), but it’s certainly intriguing.

-Thufir
