Submitting data from view to controller without using form o

Hi Guys,
My first post (and second RoR app ever!) so expect an easy problem,

I’ve been making a blog (suprise suprise, my first app was a webstore
too!), and I’ve got a charming front page, listing my posts with some
nice css and a really clean interface. Beneath each post I have a
comments form, with a name field, a textarea for the body, and a
submit post button. Easy!
The form’s action is set to call the ‘add_comment’ action in my
controller, and the input fields are set to correspond to
and comment.body in the Comment object. This all works perfectly! I
pull out the comment object from params with params[:comment] and toss
it into the database with, only to see exceptions that I
haven’t told the comment which post it belongs to! (post_id is not
null, see below)
In the comments table in my database, there are: id, post_id, name,
body. post_id is linked to the posts table by id, and I’ve done all
the work to set this up correctly.

My question is:
Does the Comment object have a post_id property from the table?
If so, how do I set it from within my blog.rhtml page? I currently
have a “for post in @posts” loop, and so post corresponds to the
relavent post_id. Bear in mind that I’m using multiple duplicate
If not, how do I set the post_id property?

Thanks a lot, I’m sure this is a really obvious one I’ve totally
Sebastian Wolf

It would help to see the relevant code.

Yes, there will be a ‘post_id’ property on your comment … one way
would be to set a hidden field on your form holding the post id. There
are about 10 other ways of doing this …